3.help


#1

for( var i = 1; i <= 20; i++){
console.log(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);
}}
Oops, try again. It looks like you printed out the wrong number of items.


#2

get rid of the first "console.log(i);"


#3

I have the same issue with a similar code, and putting the console.log(i); before or after the if/else statements only changes if the prompt of either the fizz, or buzz is happening before or after the number it's looking for. Still prompts me I have an incorrect amount of entries either way, even though the code correctly recalls "Fizz" when Divisible by 3 and "Buzz" When it's divisible by 5 and "Fizzbuzz" With both. Correctly logs every number too. IDK what's wrong :confused:


#4

The Code I have on the console btw looks like this.

var FizzBuzz= [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20];
for( var i = 0; i < 20; i++) {
console.log(FizzBuzz[i]);
if(FizzBuzz[i] % 3 === 0 && FizzBuzz[i] % 5 === 0 ) {
console.log('FizzBuzz');
}else if(FizzBuzz[i] % 5 === 0) {
console.log('Buzz');
} else if(FizzBuzz[i] % 3 === 0) {
console.log('Fizz');
}
};


#5


#6

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

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

}
8
Fizz
Buzz
11
Fizz
13
14
Fizz
FizzBuzz
16
17
Fizz
19
Buzz
why does it say Oops, try again.
It looks like you printed out the wrong number of items.


#7

if(i%3===0){
    console.log("Fizz"); 
//close this if statement here.
    if(i%3===0&&i%5===0){ //make this line an else if statement
        console.log("FizzBuzz");
    }