I am attempting to change a program of mine from Python to Javascript and I was wondering if there was a JS function like the Counter function from the collections module in Pyt
Here is a simple and easy to read solution:
const word1 = "tangram" const dict1 = {} for (let char of word1){ console.log(char) if (dict1[char]){ dict1[char] += 1 }else{ dict1[char]= 1 } }