Created
December 9, 2017 18:50
-
-
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
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 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