3...and the good! Question on this


#1

for(var i = 0; i < 20; i++) {
if(i % 3 === 0){
console.log("fizz");
}
else if(i % 5 === 0){
console.log("buzz");
}
else if((i % 3) || (i % 5 === 0)) {
console.log("fizzbuzz");
}
else{
console.log(i);
}
}

Error message: Oops, try again. You printed fizz when you should have printed 1

What's happening?


#3

I actually figured it out. I was missing a === in the fizzbuzz area. Also had to switch it around.

for(var i = 1; i <= 20; i++) {

if(i % 3 === 0 && i % 5 === 0){  // this was my error, i had.... if(i %3 && i % 5)...instead of the ===     after. 
    console.log("FizzBuzz");
}
else if(i % 3 === 0){
    console.log("Fizz");
}
else if(i % 5 === 0){
    console.log("Buzz");
}
else{
    console.log(i);
}

};