abracadabra
:[['a', 5], ['b', 2], ['r', 2], ['c', 1], ['d', 1]]
[["a", 1], ["b", 1],
var orderedCount = function (text) {
arr = []
text.split('').forEach( (s,i) => {
if (!arr.includes([s])) {
arr.push([s, 1])
} else {
++arr[i][1]
}
})
return arr;
}
Object.entries(str.split('').reduce((acc, n) => (acc[n] = (acc[n] ?? 0) + 1, acc), {}))
[...[...str].reduce((acc, n) => acc.set(n, -~acc.get(n)), new Map)]
Object.values(str).sort().join('').match(/(.)\1*/g)?.map(n => [ n[0], n.length ]) ?? []
Array.from(new Set(str), n => [ n, str.split(n).length - 1 ])