Error message "expected expression, got =" in Fizzbuzz


#1



SyntaxError: expected expression, got '='


var number = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20];

for (var i = 1;  i < number.length; number++) {
if (number[i] % 5 === 0 && number[i] % 3 === 0) {
    console.log("FizzBuzz");
}
else if (number[i] % 5 === 0 && number[i] % 3 !=== 0) {
    console.log("Buzz");
}
else if (number[i] % 3 === 0 && number[i] % 5 !=== 0) {
    console.log("Fizz");
}
else {
    console.log(number[i]);
}
};
    
Hello, the code above is what I'm using for the Fizzbuzz exercise, though I keep getting the error message "expected expression, got '='.  In order to find the syntax problem, I'm looking at the code where I use the equal signs, first when I declare the variable number as an array, then in the for statement where i = 1, and then the equal sign is used in the calculations to determine if the number is divisible by three and five.   I don't see where I've misused the equal sign in place of an expression.  Any help would be greatly appreciated.


#2

does not equal is !==, using 3 equal signs is really to much.

your loop:

for (var i = 1;  i < number.length; number++)

number++? are you sure, you use i to iterate, shouldn't you increase i then?


#3

Thank you. I also changed the variable i to = 0, so that 1 is the first result displayed. Yes, you're correct in that we want the variable to increase each time we run the loop, so with "i" declared in the for loop, it should be "i++".


#4

yep, i saw that, but i left something for you to do

Solved the issue completely now?


#5

Yes, on to the next challenge.


#6