// var total = [ 0, 1, 2, 3 ].reduce(( acc, cur ) => {
// console.log(acc,cur)
// return acc + cur
// }, 0);
// console.log(total)
// var array = [[1, 2], [3, 4], [5, 6]].reduce(( acc, cur ) => {
// console.log(acc.concat(cur))
// return acc.concat(cur)
// }, []);
let names = ['tom', 'jim', 'jack', 'tom', 'jack'];
const countNames = names.reduce((allNames, name) => {
console.log(allNames,name)
if (name in allNames) {
allNames[name] ++;
}
else {
allNames[name] = 1;
}
return allNames;
}, {});
// { tom: 2, jim: 1, jack: 2 }
console