And the good..error printed out wrong number of items


#1


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


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


#2

How many should have been printed?
How many did you print?
Which should be removed, or added?
What's stopping you from doing so?

I'm not sure what you're looking for, please ask questions, describe what you want.

Also note that counting from 1 to 20 is something computers are really good at, there's no need to list such numbers in your code

You'll also generally make less mistakes, find them faster and just understand your code faster and better if you always keep your formatting neat, this doesn't take much energy to do while writing the code and it should all be neatly formatted at all times


#3

First

console.log("FizzBizz"); // look into the instructions what you should log here

Second

console.log(Fizzbuzz()); // makes only sense if your function returns something, but this is not the case

#4

Thank you I just called the function without the console log.

I appreciate your help.


#5

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