mirror of https://github.com/grafana/grafana
parent
a881497908
commit
97b087f5a5
@ -0,0 +1,8 @@ |
||||
import getFactors from 'app/core/utils/factors'; |
||||
|
||||
describe('factors', () => { |
||||
it('should return factors for 12', () => { |
||||
const factors = getFactors(12); |
||||
expect(factors).toEqual([1, 2, 3, 4, 6, 12]); |
||||
}); |
||||
}); |
||||
@ -0,0 +1,5 @@ |
||||
// Returns the factors of a number
|
||||
// Example getFactors(12) -> [1, 2, 3, 4, 6, 12]
|
||||
export default function getFactors(num: number): number[] { |
||||
return Array.from(new Array(num + 1), (_, i) => i).filter(i => num % i === 0); |
||||
} |
||||
Loading…
Reference in new issue