Nothing's working


#1

I have no idea what's wrong with this. I keep getting the error message "Unexpected token: ="
PS: I know I'm missing a bracket after the last else statement, I fixed it and it still doesnt work.

for (var = i; 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

Hi inside your for loops you put var = i instead of var i = 0, and you forgot to close the for loop }


#3

That helped, but now its saying that I printed out the wrong number of items.


#4

can your post your new code?


#5

for (var i = 0; i < 21; 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);
}
};


#6

Sorry, you should begin counting from 1 to 20 so put var i equal to 1

for (var i = 1 ....

#7

Thanks for your help, it worked :blush: