I know this ins’t the best answer but I used almost the same logic and it worked, check it out :

function factorialize(num) {

var arr = [];

if (num == 0) {

```
return 1;
```

}

while ( num > 0) {

```
arr.push(num);
num--;
```

}

var newArr = arr.reduce(function (x,y){

return x*y;

});

return newArr;

}