Need help with 3. ...And the good!


#1

So here is my code :
for( i = 1; i < 21; i++) {
console.log(i);
}
if ((i % 3 === 0) && (i % 5 === 0)) {
console.log("FizzBuzz");
}

else if (i % 3 === 0 && i % 5 !== 0) {
console.log("Fizz");
}
else if (i % 5 === 0 && i % 3 !==0) {
console.log("Buzz");
}
else {
console.log(i);
}

and on screen it prints the numbers 1 - 20 and the word Fizz after the 20, which is definitely wrong, it also keeps saying I printed out the wrong number of Items, please help.


#2

@atg28,

for( i = 1; i < 21; i++) {
 console.log(i);
}

console.log("You left the FOR-loop, i is now: "+i);

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

else if (i % 3 === 0 && i % 5 !== 0) {
 console.log("Fizz");
 }
else if (i % 5 === 0 && i % 3 !==0) {
 console.log("Buzz");
 }
else {
 console.log(i);
 }

#3

I see, so what do I do now?


#4

Never mind I understood now, thank you very much.