(3/33) Help


#1


https://www.codecademy.com/courses/spencer-sandbox/0/3?curriculum_id=506324b3a7dffd00020bf661


"Oops, try again. It looks like you printed out the wrong number of items."


for (var i = 1; i <= 19; i++) {
    if (i % 3 === 0) {
        console.log("Fizz");
    } 
    if (i % 5 === 0) {
    console.log("Buzz");
    }
    if (i % 3 === 0 && i % 5 === 0) {
        console.log("FizzBuzz");
    }
    console.log([i]);
}

May someone tell me why this is not working?

Thank you!


#2

20 is missing, your highest is 19


#3

Haha, I just seen that but still isn't working when I change i to 20 or 21.


#4

well, for a number is divisble by 3 and 5, its also divislbe by either.

so for i=15, your if condition is true, so Fizz is logged, while this should be fizzbuzz


#5

I am sorry, I still don't understand.


#6

for i=15, agree that fizzbuzz should be logged?

your code logs fizz for i=15


#7

try writing a var listing the numbers 1 through 20 then replace your 19 in the for loop with number.length or whatever you call your variable but make sure to put the .length at the end all that will happen is your numbers divisible by 3, 5, and both will be replaced with the fizz buzz or fizzbuzz as correspons with the lesson


#8

Okay, guys. I will try this when I get home. Thank you for all the replies.


#9

fizzbuzz usually requires you print out the number if they dont meet any of the other 3 conditions. You dont have an else statement for just logging the numbers not divisible by 3 or 5. Having every number logged is going to output too many. Try changing "console.log(i);" to an else statement. The other two if statements should be else if statements as well.


#10

So guys, I solved the problem! Only took about 4 days but I got it using some Googling.

for (var count = 1; count <= 20; count++) {
    if (count % 3 === 0 && count % 5 === 0) {
        console.log("FizzBuzz");    
    } else if (count % 3 === 0) {
        console.log("Fizz");    
    } else if (count % 5 === 0) {
        console.log("Buzz");    
    } else {console.log(count);}
}

#11

I like how you use the word Googling :joy:


#12