Why doesn't this work for FizzBuzz


It works properly, except for the number 15. I changed my code in the first if conditional and got the exercise correct, but I can't figure out why this code doesn't work.

for ( i = 1; i < 21; i ++) {
    if ((i%3 && i%5) === true ) {
    } else if ( i % 3 === 0) {
    } else if (i % 5 === 0) {
    } else {


for fizzbuzz, in if condition, why check if equals true? Calculating the remainder gives a number, not a boolean value

using parentheses won't work, you need to comparison at both side of the and operator, so check that i%3 equals zero and i%5 equals zero


You can try replacing the boolean value "true" with number "0" in your code.
See if that works. Otherwise try my code.
Thanks :slight_smile:


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.