Help


#1

for (x = 0; x < 21; x++){
    if (x % 3 === 0){
        console.log('Fizz');
    }
    else if (x % 5 === 0){
        console.log("Buzz");
    }
    else if(x % 5 === 0 && x % 3 === 0){
        console.log("Fizzbuzz");
    }
    else{
        console.log(x);
    }
}

printed out the wrong number of items


#2

What if i is divisible by both 3 and 5? We can only determine this if 3 and 5 are still in play, which means testing the combined condition ahead of all others. %3 and %5


#4

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