Skip to content

Instantly share code, notes, and snippets.

@meneguite
Last active October 22, 2020 11:27
Show Gist options
  • Save meneguite/44ec2f7d224f2e6056d341d4c3c877a4 to your computer and use it in GitHub Desktop.
Save meneguite/44ec2f7d224f2e6056d341d4c3c877a4 to your computer and use it in GitHub Desktop.
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