Created
January 6, 2018 23:42
-
-
Save tobiasdalhof/00d7a302229855d1715520ac48a5bf1a to your computer and use it in GitHub Desktop.
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
function alphabetPosition(text) { | |
const alphabet = 'abcdefghijklmnopqrstuvwxyz'.split('') | |
const letters = text.replace(/\s/g, '').split(''); | |
const numbers = []; | |
letters.forEach(letter => { | |
letter = letter.toLowerCase(); | |
alphabet.find((value, index) => { | |
if (value === letter) { | |
numbers.push(index + 1) | |
} | |
}); | |
}) | |
return numbers.join(' '); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment