# Introduction to Objects I Q&A

#1

...And the good! <- That is the link to the lesson I'm stuck at.
After many attempts of correcting my code, this is the final thing that the editor tells me: ReferenceError: invalid assignment left-hand side. Any suggestions? The following is my code.

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

Camillita

P.S. That is my favorite smiley face of all times.

#2

lets take a look at this line:

``if(i % 3 = 0)``

you assign i % 3 a value of zero. If you want to compare, use two equal signs (same for your else ifs)

Also, i would check first if i is divisible by 3 and 5, since otherwise it is divisible by 3 or 5, and those run first, and you will never get fizzbuzz

#3

Okay...
...The code isn't working so I'm going to give you my "up-dated" code which is this:

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

The editor tells me now Oops, try again. It looks like you printed out the wrong number of items. and on the black thing this is what comes out:

Fizz
1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
Fizz
16
17
Fizz
19
Buzz

I think I need a little more help...
Thank you

#4

your if condition should check if the number is divisible by 3 and 5. Now, if a number is divisible by 3, the else if to check of the number is divisible by 3 and 5, will never run

#5

Like this...?

``````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);
}
};``````

Thanks + Help!

#6

well, does it work? If it does, it is should be correct. To me, this looks correct. Remember, if an if evaluates to true, the else if/else never gets executed

#7

Nope. It doesn't work. The black thing just gives me this:
FizzBuzz
1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz
16
17
Fizz
19
Buzz
which is almost the same as last time. Hmmm...
And the Oops thing tells me this: Oops, try again. It looks like you printed out the wrong number of items.

#8

from the exercise: We want to count from 1 to 20.

You count from 0 to 20

#9

Oh. Ooooooooooops! Thanks a lot @stetim94! It worked!