0

Why console.log(obj[content]) First 'bike' is undefined

const data = ['car', 'car', 'truck', 'truck', 'bike', 'walk', 'car', 'van', 'bike', 'walk', 'car', 'van', 'car', 'truck' ]; let ans = data.reduce((obj,content)=>{ console.log(obj); console.log(obj[content]); if(!obj[content])obj[content]=1; else obj[content] += 1; return obj },{}); console.table(ans);

2nd Dec 2020, 5:23 PM
蕭育杭
蕭育杭 - avatar
1 Antwort
0
蕭育杭 Can you make post this code and share the link here?
3rd Dec 2020, 7:03 AM
anon