... And the good! (Syntax error)


#1

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

It gives a SyntaxError: Unexpected Token


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


#2

else can't have a condition, so on this line:

else () {

there is no need to use parentheses.


#3

I removed the parentheses but it still gives me the same error

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


#4

look to your for loop:

for (var i=; i<21; i++) { // should be var i = 0

#5

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