So the following code is what I'm trying to achieve:
var arr = [{
name: 'foo',
amount: 2
}, {
name: 'foo',
amount: 4
}, {
name: 'foo',
amount: 6
}, {
name: 'foo',
amount: 1
}, {
name: 'foo',
amount: 5
}, ];
var newArr = arr.reduce(function (a, b) {
return a.push(b.amount);
}, []);
console.log(newArr); // which I'd expect to be [2, 4, 6, 1, 5]
But this errors: Uncaught TypeError: Object 1 has no method 'push'. I know I could do this with .forEach() but I'm wondering if it's possible with .reduce()