Introduction to Objects 1; Fizz Buzz


#1

This one is driving me nuts! My interpretation is that we must print to the console 1-20 regardless, so I've done it like this:

for (count = 1; count <= 20; count ++) {
console.log(count);
}
var i = 15;

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

It then logs the numbers 1-20 and the phrase "FizzBuzz", which I thought would be correct only it keeps saying, it looks like you printed out the wrong number of items?!


#2

remove this.

thats fine

remove this from here

Also here's it below as a spoiler for you to look at if you can't interpret what I'm saying, or just want the answer.


for (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);
}
};

#3

Thanks for your help there. That makes sense now. I was misinterpreting what they actually wanted from the output.