Lesson 3


#1




Error: Unexpected token else

Not sure where I went wrong.


for (var i=1; i<=20; 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 line:

else if (i % 5 === 0);

remove the semi-colon, it prevents the else if from executing properly.


#3

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