The output is correct with bracket notation while output is something else with dot notation
let data = ['car', 'car', 'truck', 'truck', 'bike', 'walk', 'car', 'van', 'bike',
'walk', 'car', 'van', 'car', 'truck', 'Pogo '];
let instance_1 = data.reduce((acc, elm) => {
if(!acc[elm]){
acc[elm] = 0;
}
acc[elm]++;
return acc;
}, {})
console.log(instance_1)
let instance_2 = data.reduce((acc, elm) => {
if(!acc.elm) {
acc.elm = 0;
}
acc.elm++;
return acc;
}, {})
console.log(instance_2);
Your help is much appreciated...