# Help, to understand what's incorrect! Introduction to Objects I 3/33

#1

Hi, help please to understand what's incorrect in my code!!!!
Print out the numbers from 1 - 20.
The rules:
For numbers divisible by 3, print out "Fizz".
For numbers divisible by 5, print out "Buzz".
For numbers divisible by both 3 and 5, print out "FizzBuzz" in the console.
Otherwise, just print out the number.

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

#2
for(i=1; 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);
}
}

#3

your code is correct also but it has a problem when you use it in codeacademy console;

#4

My code is similar and and doesn't run:
for(i=1;i<20;i++){
{if (i%15 === 0) //check if divisible by 15
{console.log("FizzBuzz")
;}
else if //check if divisible by 5
(i%5 === 0)
{console.log("Buzz")
;}
else if //check if divisible by 3
(i%3 === 0)
{console.log("Fizz")
;}
else //print the number
{console.log(i);}
};

#5

Fixed it - I won't post the correct code- but it's almost correct. but I had one extra open brace. Also needed to change the 20 to 21. Working fine now.

#7

So, I seem to have the exact same code as you, but i keep getting a weird error i don't get. It says "You printed FizzBuzz when you should have printed Buzz".

Does anyone have an idea how to get past this seemingly bug in the course?