I hereby claim:
- I am mhmdshorafa on github.
- I am mhmdshorafa (https://keybase.io/mhmdshorafa) on keybase.
- I have a public key ASBzc4MvLPyrfflMidihv-B7AhgAU2qdK1vCeHfBfXWzKwo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
const firstNonRepeatingLetter = (inputString) => { | |
const letters = inputString.toLowerCase().split(''); | |
const firstNonRepeated = letters.map( letter => letters.filter( l => letter === l )).filter(repeated => repeated.length === 1); | |
const nonRepeated = firstNonRepeated[0]; | |
if (nonRepeated === undefined) return ''; | |
else return inputString[letters.indexOf(nonRepeated[0])]; | |
} | |
module.exports = firstNonRepeatingLetter; |