algorithms/fizzbuzz/fizzbuzz.ts

21 lines
412 B
TypeScript
Raw Permalink Normal View History

2024-01-12 09:36:47 -05:00
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);