Why is it that when I want to use the push function inside the reduce function to return a new array I get an error. However, when I use the concat method inside the reduce
I know this is the same answer, but I just want to show that using reduce (), the syntax can also be reduced to a single line of code using ES6:
reduce ()
var store = [0,1,2,3,4]; var stored = store.reduce((pV,cV) => [...pV, cV], []); console.log(stored);