[3] ...And The Good


#1

I am so confused on this. I have tried this, what feels like a hundred different ways. Help please?

Error Message: Oops, try again. It looks like you printed out the wrong number of items.

Here is my code:

var num = 20;

for (x = 1; x <= num; x++) {
    if (x % 3 === 0 && x % 5 === 0) {
        console.log("FizzBuzz");
    }
    else if (x % 3 === 0) {
        console.log("Fizz");
    }
    else if (x % 5 === 0) {
        console.log("Buzz");
    }
    else {
        console.log(x);
    };
};

#2

Couple things to point out. You have an unnecessary semicolon after your else statement closing bracket, and in your for loop you need to put var x = 1 not x = 1 - since x hasn't been previously declared.


#3

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