Last active
December 27, 2021 12:17
-
-
Save jafar-jabr/f749406acfd2b9965a57ccdf8b87e759 to your computer and use it in GitHub Desktop.
Javascript get first unique character
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
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