DEV Community

bomoniyi
bomoniyi

Posted on

Javascript Code for fizz buzz

for (let i = 1; i < 101; i++) {
  if ( Number.isInteger(i/15) === true) {
  console.log("fizzbuzz");
} else if (Number.isInteger(i/5) === true) {
  console.log("buzz");
} else if (Number.isInteger(i/3) === true){
  console.log("fizz");
} else {
  console.log(i); }
}
Enter fullscreen mode Exit fullscreen mode

Top comments (1)

Collapse
 
jonrandy profile image
Jon Randy 🎖️ • Edited
for (let i=1,f='fizz',b='buzz'; i<101; i++)
  console.log([i,f,b,f+b][!(i%5)*2+!(i%3)])
Enter fullscreen mode Exit fullscreen mode

😝