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


#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.


Replace this line with your code. 
for(var i = 0;i<=21;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

Instructions:

Print out the numbers from 1 - 20.


for(var i = 0;i<=21;i++) // so you should take i=1

next

The rules:
For numbers divisible by 3, print out "Fizz".
For numbers divisible by 5, print out "Buzz".
For numbers divisible by both 3 and 5, print out "FizzBuzz" in the console.

how if else work:

if first condition is false
then it'll check second condition
if it's too false
then it'll check third condition
if it's too false
then it'll print else statement.
but if first condition is true
then it'll not go in second condition.

so when i=15

It'll check

if((i % 3) === 0)

that is true.so it'll print "Fizz".did you really want that?

make sense :slight_smile:


#3

thanks!:stuck_out_tongue:


#4

What is he supposed to do instead of if/else??


#5

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