Skip to content

Instantly share code, notes, and snippets.

@b-coimbra
Last active February 29, 2020 01:05
Show Gist options
  • Save b-coimbra/b7e71cc20a6ac1c4fb4d38c19b515ab5 to your computer and use it in GitHub Desktop.
Save b-coimbra/b7e71cc20a6ac1c4fb4d38c19b515ab5 to your computer and use it in GitHub Desktop.
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