What am i doing wrong?


#1


https://codecademy.com/courses/spencer-sandbox/0/3?curriculum_id=506324b3a7dffd00020bf661#


it keeps saying i printed out the wrong number of items :confused:


var numbers = function (divisibleBy){
    
for (var n=1; n<21; n++) {
    
    if (n % 3 === 0){
        
        console.log('Fizz');
        }
    else if (n % 5 === 0){
        
        console.log('Buzz');
        }
    else if (n % 3 && n % 5){
        
        console.log('FizzBuzz');
        }
    else {
        
        console.log(n);
        }
    
    
    }
    };


#2

Instead of having

Have it so that

Comes first, so it looks like this:

for (var i = 1; i <= count; 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

This code is not passing. Your count is not defined.
for (var n = 1; n <= 20; n++) {
var output = "";
if (n % 3 ===0)
output += "Fizz";
if (n % 5 === 0)
output += "Buzz";
console.log(output || n);
}


#4

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