Count the frequency of each character in a string
Sigiloso
const a = "iamatravellerhavingtotravelataspeedof1"; const res = {}; const m = a.split(""); m.forEach(ele=>{res[ele] = m.filter(x=>x===ele).length;}) // res = {1: 1, i: 2, a: 7, m: 1, t: 4, r: 3, …}