# 3/5 Keeps saying "SyntaxError: Unexpected token {", and i'm not sure where is that extra {

#1

var number = 21;
for ( var i=1; i< number; 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);
}
};

#2

You are missing closing parenthesis on the second "else if" condition

#3

Thank you, you are right.I was focusing on the {.

#7
``````var i = 0;

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

}``````

#8

Why is the the first if statement?

if(i % 3===0 && i % 5===0){
console.log("FizzBuzz");
}

#9

Why is the first if statement?

if(i % 3===0 && i % 5===0){
console.log("FizzBuzz");
}

#10

Kev136:

``````if(i % 3===0 && i % 5===0){
console.log("FizzBuzz");
}``````

It needs to be first because if you have i % 3 === 0 or i % 5 === 0 by itself first, it wont ever calculate fizzbuzz together because the program sees the other ones first.

#11

#12

Could you please elaborate your explanation.I am a bit confused about why we can't write 'FizzBuzz' in first place.

#13

I am not sure if you are still confused but the order is important because a program runs the order from top to bottom. There are ways to group things that allow them to happen even if other things have happened but if we put if the if (x % 3 ===0) first then it would print out "Fizz" for numbers divisible by 3 & 5 because it was told to print out Fizz for numbers divisible by 3 before it was told to print out "FizzBuzz" for numbers divisible by 3 and 5. If we put the "FizzBuzz" info first then the program goes through and finds the numbers divisible by 3 and 5 and replaces them with "FizzBuzz" then it goes through and does just 3's and then just 5's and finally it ends with the remaining numbers.

#14

thanks a lot.I understood your explanation.