May you please help me debug my code


for(var i=0; i<21; i+=){
    if(i%3==0 && !i%5==0){
    else if(!i%3==0 && i%5==0){
else if (i%3==0&& i%5==0){


Remove the ! on this line,

Remove the one on this line as well,

And also you can turn this into an else statement by removing the condition (i%3==0&& i%5==0) and writing else instead of else if

else syntax in JS looks like,

else {


Hello, on your for condition instead of i++ you put i+=. Correct it and try again.


your for loop:

for(var i=0; i<21; i+=)

i+=? i plus what? you could use ++ as a shorthand, but if you use += you do have to use a value with which i should be increased

the loop should work for the numbers 1 till 20, not 0 till 20 like your loop.

uhm... if a number is divisible by 3 and 5, it also divisible by 3 or 5, with other words, to check if a number is divisible by both, should be your if condition. otherwise, you will never get fizzbuzz

if a number is not fizz, not buzz or not fizzbuzz, the number itself should be printed, this is not happening in your code


Thank you, but I still can't get FizzBuzz and it's saying it's logging to many item.
for(var i=0; i<21; i+=1){
if(i&3==0 && i%5==0){
else if(i%3==0){
else if (i%5==0){




you decided to use & for a reason i can't understand, rather then the modulo operator.


Thank You for helping me.


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