3 ...And the good! "It looks like you printed out the wrong number of items"


#1

3 ...And the good!
I've been over this code so many times and I can't find where I'm going wrong. Any help would be wonderful.
The error message is: "Oops, try again. Looks like you printed out the wrong number of items."

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

#2

This phrase should be nested in two parentheses like so,

((i % 3 === 0) && (i % 5 === 0))


#3

@christhemorton,
For the Javascript interpreter a semi-colon-; is an End-of-Statement indicator....

If you use

for (var i=1; i<21; i++);

the corresponding code-block encapsulated in a pair of curly-brackets { } is NOT executed !!!!


#4

Thanks for the explanation!


#5

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