FizzBuzz Problem
Maulik Sompura

Maulik Sompura
A well know logical question that you may face in a tech interview is FizzBuzz Problem. The Problem statement is something like below:
Write a program that prints the numbers from 1 to 100. For multiples of three, print "Fizz" instead of the number; for multiples of five, print "Buzz"; and for numbers that are multiples of both three and five, print "FizzBuzz".
A simple Javascript solution to this is given below:
for (var i = 0; i <= 100; i++) {
if (i % 3 == 0 && i % 5 == 0) {
console.log("FizzBuzz");
} else if (i % 3 == 0) {
console.log("Fizz");
} else if (i % 5 == 0) {
console.log("Buzz");
} else {
console.log(i);
}
}
This question can be modified in several way, one of which is "if the number is multiple of 3 or 5 print Buzz else Fizz". Write a solution in comment for this one.
Fun fact: The FizzBuzz problem is discussed in StackOverflow's 2019 Annual survey