I have this function
function fizzbuzz(n){
var arr = [];
for(var i = n; i > 0; i--){
if(i % 3 === 0){
console.log("Fizz")
}
if(i % 5 === 0 ){
console.log("Buzz")
}
if(i % 5 === 0 && i % 3 === 0){
console.log("Fizzbuzz")
}
else {
console.log(i);
}
arr.push(i);
}
return arr;
}
and I want to be able to store everything in the empty array. However, with my current code, the if statements
aren’t copied onto the array. It returns this
fizzbuzz(30)
[ 30,
29,
28,
27,
26,
25,
24,
23,
22,
21,
20,
19,
18,
17,
16,
15,
14,
13,
12,
11,
10,
9,
8,
7,
6,
5,
4,
3,
2,
1 ]
What else do I need to change in order for the if statements to be on the array?