DEV Community

Niharika Pujari
Niharika Pujari

Posted on

Fizz? Buzz? FizzBuzzz!

Interview Question:

Write a short program that prints each number from 0 to 100 on a new line.

For each multiple of 3, print "Fizz" instead of the number.
For each multiple of 5, print "Buzz" instead of the number.
For numbers which are multiples of both 3 and 5, print "FizzBuzz" instead of the number.

Solution 1:

Alt Text

Solution 2:

Alt Text

Comment below your approach!

Top comments (5)

Collapse
 
peledzohar profile image
Zohar Peled

prints each number from 1 to 100 - then why your loop starts at 0?

Collapse
 
niharikapujari profile image
Niharika Pujari

Typo @zohar ++

Collapse
 
trinadhkoya9 profile image
Trinadh Koya

Looks like I solved this problem a few months back on Hacker rank or somewhere

Collapse
 
lallenfrancisl profile image
Allen Francis

How the heck !!!!!!!

Collapse
 
peledzohar profile image
Zohar Peled

Javascript is a weakly typed language, so '' || i is basically translated to i because '' is implicitly converted to false.