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

19 lines
407 B
JavaScript

function fizzBuzz(stopNumber) {
var 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);