What is wrong with my FizzBuzz program


#1


SyntaxError: Unexpected token {


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


#2

 // you need to close condition: put ) before {
 else if(array[i- 1]%3 === 0 && (array[i- 1]%5 === 0) {

But I didn't catch what are you trying to do..


#3

@denys.matsevych is right about the parentheses.

@ishaansmasher100, you should also consider the logic/flow of your program. for 15, your program would log Fizz while it should log Fizzbuzz


#4

first iterate the number from 1 to 20 using for loop
-inside the for loop log the "FizzBuzz" first using if and then log the "Fizz" and "Buzz" to the console.

keep your code simple


#5

Thank you everyone for helping me


#6