It looks like you printed out the wrong number of items


#1

for (var i = 1; i < 21; i++) {
console.log(i);
}
if(i / 3) {
console.log("Fizz");
}else if(i / 5){
console.log("Buzz");
}else if(i / 3 & 5) {
console.log("FizzBuzz");
}else{
console.log(i)
};

What am i doing wrong?
@albionsrefuge @ionatan @amanuel2


#2

i will resolve it soon. What task is this? Along with number/


#3

Task number 3. ....And the good


#4

Ohh, you just messud up the simple. Nothing to bad instead of a division sign(/) you where suppose to but a modulous operator(%). And at the last one where it says and this is not how you do it:

Its like this:

else if(i%3 && i%5==0){
// Do this
}

#5

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

New Code and now it is saying It looks like you printed out the wrong number of items.


#6

Dude, in the for loop the instructions say that your suppose to put your conditonal statements inside it. so you do this, plus you have to check if the modulus is equal to 0 for each one, whitch means if the remainder of thier divison is 0. So like this

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

#7

I did that and now it says You printed Fizz when you should have printed FizzBuzz


#8

Wow. Did not expect that. I will edit this anwser when i get solution..><


#9

Apparently switching orders matter...........

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");
}

else {
console.log(i);
}

3...And the Good:: Missing after for-loop initializer!