var firstUniqChar = function(s) {
for(let i = 0; i < s.length; i++) {
if( s.indexOf( s.substring(i, i + 1) ) === s.lastIndexOf( s.substring(i, i + 1) ) ) {
return i
}
}
return -1
};
var firstUniqChar = function(s) {
const letterCounter = {}
for(const letter of s) {
if(letterCounter[letter]) letterCounter[letter]++
else letterCounter[letter] = 1
}
for( let i = 0; i < s.length; i++) {
const stringLetter = s[i]
if (letterCounter[stringLetter] === 1) {
return i
}
}
return -1
};
var firstUniqChar = function(s) {
for( let i = 0; i < s.length; i++) {
const letter = s[i]
if(s.indexOf(letter) === s.lastIndexOf(letter)) {
return i
}
}
return -1
};