3...And the Good


Why is this not correct?

for (var i=1; i<=20; i++) {
if(i%3===0 && i%5===0) {
else if
(i%3===0 )

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


We never write a semi-colon before an else.

We never write an opening brace before the conditional expression in an if statement.


Syntax error at the 4th line of your code. Placement of the semicolon needs attention. You have written:

Your semicolon should be inside the curly bracket. Like this:

Check the 'else if' as suggested by mtf.

And an extra semicolon at the end of the entire code which is not required. Get rid of the last semicolon.

It is always a good idea to check your syntax thoroughly before asking help. It will help you in the long run. As things might get more complex. Another good practice is writing the code with proper indentation.


I sometimes do not follow indentation and then my code get really messy. :stuck_out_tongue_winking_eye: