Introduction to Objects I Q&A


#1

I am stuck on lesson 3/33 ...And the Good! The editor tells me that SyntaxError: missing after for-loop initializer
Here's my code:

for(i = 0, i <= 20, i++) {
console.log(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");
}
};

Thank you in advance! :smile:


#2

you have to use semicolons inside for loop statements:

https://www.codecademy.com/blog/78


#3

Also this wont pass because, it will never print FizzBuzz because it wont check if a numbers divisible by 3 and 5 if it's already been checked if its divisible by 3 OR 5, so for 15 it will print Fizz instead of FizzBuzz. Swap the order of if, else if, else statements.


#4

Thanks @puristaja and @benjnev!