3/33 It looks like you printed the wrong number of items


When I run the code it prints each number twice.

for (var i = 1; i <= 20; i++) {
if (i % 3 === 0 && i % 5 === 0) {
} else if (i % 5 === 0) {
} else if (i % 3 === 0) {
} else {

PS: I see how having two console.log(i) would do that, but what do I put for an else statement?


Do you think that is the console.log that is causing too many lines to print?


I thought having it written twice in the for loop might be causing it. If that isn't correct then I'm not sure. I've looked in similar threads and their code appears to be identical, or almost identical, to mine.

I ran the original for loop and it worked fine before I added the if/else statement.


You are correct about that.


If I write it outside the loop I get "SyntaxError: expected expression, got keyword 'else'". And If I leave else blank I get the same message as before and only the numbers divisible by 3 and 5 or both print twice.

Wait, never mind, I got it. I forgot I had to move the console.log from the top into the else nest.


I asked you about this earlier ... why do you think that the console.log in your else block is the problem?


Sorry I just realized what I did, I edited it into my previous reply.