Created
September 27, 2017 18:51
-
-
Save alexbrillant/03dd9c68f7cfe91ab93da1a841481f4c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export function occurenceOfCharacters (string) { | |
| const map = new Map() | |
| for (let i = 0; i < string.length; i++) { | |
| const char = string[i] | |
| if (!map.get(char)) { | |
| map.set(char, 1) | |
| } else { | |
| const currentCount = map.get(char) | |
| map.set(char, currentCount + 1) | |
| } | |
| } | |
| return map | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment