Last active
February 29, 2020 01:05
-
-
Save b-coimbra/b7e71cc20a6ac1c4fb4d38c19b515ab5 to your computer and use it in GitHub Desktop.
This file contains 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
function firstNonRepeatableChar(string) { | |
let chars = []; | |
[...string].forEach(letter => { | |
if (!(letter in chars)) | |
chars[letter] = 0; | |
chars[letter] += 1; | |
}); | |
return Object.keys(chars).filter(c => chars[c] === 1)[0]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment