# Stuck on 3

#1

keeps saying
Oops, try again. You printed Fizz when you should have printed 1

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

#2

You should make all these triple equal to ( === ), so that it doesn't only check the value, but also the datatype.

Finally, this for loop will cause you to print "FizzBuzz" before printing 1 rather than just one first in the console. So, you should start i at 1 and then set it less than or equal to 20.

I hope this helps!

#3

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

#4

keeps saying Oops, try again. There was a problem with your syntax.

#5

But you've not fully implemented my suggestion.

How about the triple equal to?

#6

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

whats wrong

#7

You're missing the opening curly brace for your last else if statement.

Now, I'm a bit unsure of what's going on. I don't seem to have added anything to your code except re-ordering the condition and it passes all test for the exercise. See below.

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

Oops, try again. You printed Fizz when you should have printed FizzBuzz
#8

if (i % 5 === 0&& i % 3 === 0) {
what did you write this first
do they have to be in oder

#9

Same thoughts here! Re-ordering seems to pass all script test for the exercise.

#10

okay thanks so much for you help

#11

You're welcome.

Have fun coding!

#12

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.