Search This Blog

2023/07/25

FizzBuzz Challenge

 What is FizzBuzz?


FizzBuzz is a task where the programmer is asked to print numbers from 1 to 100,
but heres the catch, multiple of three should printFizzand similarly printBuzzfor multiples of 5
and lastly printFizzBuzzfor multiples of three and five.


for (let i = 1; i < 101; i++) {
if (i % 15 == 0) {
console.log("FizzBuzz")
}
else if (i % 5 == 0) {
console.log("Buzz")
}
else if (i % 3 == 0) {
console.log("Fizz")
}
else {
console.log(i)
}
}

No comments:

Post a Comment