Write a function duplicateCounts(text) that finds the duplicate characters in text and says how many times each of them occurs.
text is a string. It can be empty. It has no tabs or line breaks.text. Not a Map.'a' and 'A' are different characters, so 'aA' gives {}.{}.The object itself can be your counter: one key per character.
duplicateCounts('hello world')Returns { l: 3, o: 2 }
duplicateCounts('1121')Returns { '1': 3 }
duplicateCounts('abc')Returns {}
Asked at Amadeus Labs · Source
duplicateCounts('hello world'){ l: 3, o: 2 }duplicateCounts('banana'){ a: 3, n: 2 }duplicateCounts('abc'){}Hidden tests run on Submit.