Skip to content

Instantly share code, notes, and snippets.

@jafar-jabr
Last active December 27, 2021 12:17
Show Gist options
  • Save jafar-jabr/f749406acfd2b9965a57ccdf8b87e759 to your computer and use it in GitHub Desktop.
Save jafar-jabr/f749406acfd2b9965a57ccdf8b87e759 to your computer and use it in GitHub Desktop.
Javascript get first unique character
const firstUniqChar = (_str) => {
for (let i= 0; i < _str.length; i+= 1) {
if (_str.indexOf(_str[i]) === _str.lastIndexOf(_str[i])) return i+1;
}
return -1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment