algorithms/fizzbuzz/fizzbuzz.ts
2024-01-12 09:36:47 -05:00

20 lines
412 B
TypeScript

function fizzBuzz(stopNumber: number) {
let i = 1;
while (i < stopNumber + 1) {
if (i % 5 === 0 && i % 3 === 0) {
console.log('FizzBuzz');
}
else if (i % 3 === 0) {
console.log('Fizz')
}
else if (i % 5 === 0) {
console.log('Buzz')
}
else {
console.log(i)
}
i++
}
}
fizzBuzz(30);