...And the good! Syntax error


#1


https://www.codecademy.com/courses/spencer-sandbox/0/3?curriculum_id=506324b3a7dffd00020bf661#


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)}
    }


#2

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


#3

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

should be

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


#4

Nope my bad. You are right..


#5

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?


#6

@melog93 Yes, quite accurate.


#7

doesn't work, same error


#8

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


#9

@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.


#10

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


#11

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