Last active
September 25, 2022 08:52
-
-
Save buymed-hoangpham/7d29eb64057fd46a943f03dc345253f3 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
| const countCharacters = (str) => { | |
| const result = {}; | |
| const arr = str.split(''); | |
| for (word of arr) { | |
| if (result[word]) { | |
| result[word]++; | |
| } else { | |
| result[word] = 1; | |
| } | |
| } | |
| return result; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment