[SOLVED] 3/33 And the good, really don't know about this problem


#1

For the first time I create a new topic. The problem is " its look like you printed out the wrong number of items";

Here is all my code

for(var number = 0; number <= 20; number++){
    if((number % 3 == 0) && (number % 5 == 0)){
        console.log(number + " : FizzBuzz");
    }
    else if(number % 3 == 0){
        console.log(number + " : Fizz");
    }
    else if(number % 5 == 0){
        console.log(number + " : Buzz");
        }
    else {
        console.log(number);
    }
}

PLEASE HELP ME SIR. Thank you.


#2

The exercise expects you to start at 1


#3

Hi, I had the same result after created just like what you have. After frustrated for a while, I ended it embeded another If/else statement, which works fine now. Here is my code:

for (var count = 1; count <= 20; count++){
     if(count % 3 === 0){
        if(count % 5 === 0){
            console.log("FizzBuzz");
            }
        else{
             console.log("Fizz");
         }
    }else if(count % 5 === 0){
        console.log("Buzz");
        }
    else{
        console.log(count);
        }

#4

The last closing bracket is missed from the previous.

for (var count = 1; count <= 20; count++){
if(count % 3 === 0){
if(count % 5 === 0){
console.log("FizzBuzz");
}
else{
console.log("Fizz");
}
}else if(count % 5 === 0){
console.log("Buzz");
}
else{
console.log(count);
}

}