Why is array inside array being created every time

I m running the fizzbuzz code and I am having the right answer but for every loop it has a array e.g

[[1],[2],[3]]

why not it is

[1,2,3]

following is my code

const results = [];

const fizzbuzz = (n) => {
  // ADD CODE HERE...
  for(let i = 1; i <= n; i++){
    if(i % 3 == 0 && i % 5 ==0){
    results.push(`fizzbuzz`)
    }else if(i % 3 == 0){
      results.push("fizz")
    }else if(i % 5 == 0){
       results.push(`buzz`)
    }else{
      results.push([i])
    }
  }
};

fizzbuzz(16);
console.log(results);

here is the [link](https://repl.it/talk/share/fizzbuzz/119173)

Hello there,

That line is pushing an array containing i into results which is an array…

Hope this helps

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