Count Characters in a String .forEach function count(string) { history = {}{ string.split("") .forEach(char => { if(history[char]){ history[char]++ } else { history[char] = 1 } }) return history } .reduce function count(string) { return string.split("") .reduce((acc, curr) => { acc[curr] ? acc[curr]++ : acc[curr] = 1 return acc }, {}) } Delete Occurrences of an Element after N Repetitions .filter function deleteNth(arr,x){ let counter = {} return arr.filter((val) => { counter[val] ? counter[val]++ : counter[val] = 1 if(counter[val] <= x) { return val } }) }