I'm getting this error. Kindly note splits
is an array with values.
TypeError: Cannot read property 'push' of undefined
on
var products = splits.reduce((accu, curr) => {
if (accu[curr[0]] === null) {
accu[curr[0]] = [];
}
accu[curr[0]].push(curr[1]);
return accu;
}, {});
var result = Object.keys(products).map(key => `${key} - ${products[key].join(', ')}.`).join(' ');
Appreciate anyone helps to fix the above code