function count(str) { let obj = {}; let arr = [...str]; arr.map(n => { if (n != false && obj[n] != undefined) { obj[n]++; } else { obj[n] = 1; } }) return obj; }