Skip to content

Instantly share code, notes, and snippets.

@Alaa-Khattab
Created December 9, 2017 18:50
Show Gist options
  • Save Alaa-Khattab/7ba97b16bfbf78b1981755926fd40668 to your computer and use it in GitHub Desktop.
Save Alaa-Khattab/7ba97b16bfbf78b1981755926fd40668 to your computer and use it in GitHub Desktop.
create function returns the first character that is not repeated anywhere in the string. Alaa-Khattab
const firstNonRepeatingLetter = (input)=>{
var inputChar = input.split('');
var result = ""
for(x = 0 ; x < inputChar.length ; x++){
var newChar = input.toLowerCase().split('')
newChar.splice(x,1)
if(!newChar.includes(inputChar[x].toLowerCase())){
result = inputChar[x];
break;
}
}
return result;
}
firstNonRepeatingLetter("sTreSS");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment