"syntax error"


#1

//var num=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20];
for(var i=0; i<20; i++){
if (i%3===0){
console.log("Fizz");
}
else if (i%5===0){
console.log("Buzz");
}
else if ((i%5===0) && (i%3===0){
console.log("FizzBuzz");
}
else{
return i;
}
}

it's telling me that there is a syntax error.


#2

It might be because you used "return" for the last else condition but used "console.log" for the first three conditions. Also you dont need the first line with var num=[1,2,3,...].


#3

Ok i fixed it and tried this and it still gives me an error.

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

}