I Don't Understand Why This is Wrong


#1

I am currently working on Introduction to Objects I part 3 ("...And the Good!"). I was instructed to use a nested conditional, and I thought I did. I keep getting an error saying "SyntaxError: Expected ';' ". This is my code:

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

I don't understand what's wrong. Please help! Thanks :slightly_smiling:


#2

Instead of int you should put var
And your statement should have that structure

if (condition ) {

}
else if ( condition ) {

}
else  {

}

#4

Ah I see. I always overlook smaller things like that. Thank you!