Last active
October 22, 2020 11:27
-
-
Save meneguite/44ec2f7d224f2e6056d341d4c3c877a4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Array<T> { | |
fill(value: T): Array<T>; | |
} | |
const isMultiple = (n: number, m:number) => n % m === 0; | |
const normalize = (n: number): string => { | |
if (isMultiple(n, 35)) { | |
return 'Nama Team'; | |
} | |
if (isMultiple(n, 7)) { | |
return 'Team'; | |
} | |
if (isMultiple(n, 5)) { | |
return 'Nama'; | |
} | |
return n.toString(); | |
} | |
const generateNumbers = (length: number) => { | |
const numbers: number[] = Array<number>(length).fill(0).map((e, i) => (i + 1)); | |
return numbers.map((n) => normalize(n)).join(', '); | |
}; | |
const numbers = generateNumbers(100); | |
console.log(numbers); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment