FizzBuzz


#1

Oops, try again.
Your code doesn't look quite right. Check the Hint if you need help!


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


#2

btw i put the quotation after fizzbuzz still dont work


#3

20 is currently not included, are you sure it doesn't have to be?

the logic of your program is also slightly flawed, a number divisible by 3 and 5 is also divisible by either one of this number, so currently fizzbuzz will never be printed, to print fizzbuzz should come first

a single equal sign assigns a value, for comparison use two equal signs


#4

did everything you said (I think) still wont work

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


#5

Your problem is here when evaluating if i is divisible by 5 you put one equal sign = instead of two ==

should be,

else if(i % 3 == 0 && i % 5 == 0)


#6

still dont work

SyntaxError: expected expression, got keyword 'else'


#7

what exercise and unit are you on?


#8

and the good

intro to objects 1


#9

the closing curly bracket (}) of a if,else ifandelse shouldn't have a semi-colon after it, it prevents the entire clause from executing correctly


#10

sorry for bieng so dumb, what you said worked but now its saying

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

when theres clearly 1-20 being printed

Again my code

for(var i = 1; i <= 20; i ++)
{

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

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


#11

this code:

{
    console.log(i)
}

where did the else keyword go? I only said you had to remove the semi-colons


#13

omg lol soz dont know why it wasnt there thnx


#14