I'm having problem with my FizzBuzz


#1


var numbers= [];
function game(array, start, end){
    for(var a= start; a< end; a++){
    array.push[a];
    }
    for(var i= 0; i< array.length; i++){
    if(array[i]%3 === 0){
        console.log("Fizz");
    }
    else if(array[i]%5 === 0){
        console.log("Buzz");
    }
    else if(array[i]%3 === 0 && array[i- 1]%5 === 0){
        console.log("FizzBuzz");
    }
    else{
        console.log(array[i]);
    }
    }
}
game(numbers, 1, 20)


#2

push() is a built in function, function require parentheses, not square brackets

for 15 fizz is printed, this should be fizzbuzz


#3

A post was split to a new topic: Fizzbuzz


#4

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