Help, stuck in 3. Can't figure out what is wrong with my code


#1

I'm stuck in 3 - And the good topic. Error says problem with syntax and unexpected token ')'.

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

thank you in advance!


#2

oops nevermind,I found my mistake, i used ',' instead of ';' inside my for loop condition.


#3

In this part:

for (i = 1, i<21, i++){

you need to separate each section with a semicolon ; instead of a comma , Like so;

for (i = 1; i < 21; i ++;){

#4

Hi, I can't figure out what is wrong with this code:
for ( var i=1; 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");
}
else {
console.log(i);
}

}

Can you please help me? Thank you in advance!


#5

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