..and the good


#1


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


when i press save and sumbit it get strucks


Replace this line with your code. 
for(var i= 1;1<=20;i++)
{
    if((i%3===0)&&(i%5===0))
    {
        console.log("FizzBuzz");
    }
    else if(i%3===0)
    {
        console.log("Fizz");
    }
    else if(i%5===0)
    {
        console.log("Buzz");
    }
    else
    {
        console.log(i);
    }
}


#2

Check for the conditions respectively don't start with the last one. Control Flow should be,

  1. i % 3 == 0

  2. i % 5 == 0

  3. i % 15 == 0


#3

sorry i am not getting you


#4

Your if/else if statements should be in this order,

in order to get the desired result.


#5

for(var i= 1;1<=20;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);
}
}

still same error


#6

Check if i % 15 instead of 3 and 5,

checking for((i%3===0)&&(i%5===0)) will conflict with your first and second conditions.


#7

You also need to have the (i % 15 === 0) before the 3 or the 5 because then the code reads the top one first and sees that it is divisible by 3 or 5 and will therefore print out that it is only divisible by 3 or 5. It checks the top one, and if that's not true it moves on to the second one, and the third and so one, but because the top one is true, it doesn't have to check the ones below. So put (i % 15 == 0) first (It should an 'if', rather than an 'else if' ). I hope that was somewhat useful to you.


#8

for(var i= 1;1"<=20";i++) <--- change whats in quotes to just "<" and put "21"

Remember that the start count is the number you choose, but in the ending digit if you want the count to end at 20 you go one over and put 21. you want the ending number to be 21 then your code should go one over to 22. it was in the lesson, I just solved it right now. hope this helps :slight_smile:


#9

got it was very helpful thank you


#10

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