...And the good! Syntax error



SyntaxError: expected expression, got ')'

Am I blind of i missed some magic?

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


Semicolons after your loop, and after all your 'console.log's.


if(i%3===0 && i%5===0){console.log("FizzBuzz")}

should be

if(i%3===0 && i%5===0){console.log("FizzBuzz"){


Nope my bad. You are right..


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

if(i%3===0 && i%5===0){console.log("FizzBuzz");}
else if(i%5===0){console.log("Buzz");}
else if(i%3===0){console.log("Fizz");}
else {console.log(i);}

Something like this?


@melog93 Yes, quite accurate.


doesn't work, same error


Looks OK. Is there any other code on your exercise?


@melog93, actually your code is correct but not so clean. I've tried your code and passed the lesson. I think you need to refresh/reset the lesson.

@shrike2 , for loop and if/else statement does not have semi-colon at the end.


yes, after refreshing the page everything works correctly, thanks.


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