Last active
December 7, 2018 15:13
-
-
Save mornir/1fc32606f11e6fb57c7190fe3d9baddb to your computer and use it in GitHub Desktop.
alphabetPosition
This file contains hidden or 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
function alphabetPosition(text) { | |
const arrayOfLetters = text.toLowerCase().split('') | |
return arrayOfLetters.map(letter => { | |
const code = letter.charCodeAt() | |
if(code < 97 || code > 122) return null | |
return code - 96 | |
}).filter(num => num !== null).join(' ') | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment