DEV Community

Discussion on: [Challenge] 🐝 FizzBuzz without if/else

Collapse
 
ehsan profile image
Ehsan Azizi • Edited

Here is an ugly solution in one line

for (let i = 1; i <= number; i++) {
  console.log((i % 3 === 0 && i % 5 === 0 && 'fizzbuzz') || (i % 3 === 0 && 'fizz') || (i % 5 === 0 && 'buzz') || i);
}
Collapse
 
shravan20 profile image
Shravan Kumar B

U aren't supposed to use Ternary Operator.

Collapse
 
ehsan profile image
Ehsan Azizi • Edited

Oh yeah! didn't notice that, I have updated my solution