Created
April 12, 2020 20:52
-
-
Save inodaf/1785fe55f9b01bfda686914d2cb5a40f to your computer and use it in GitHub Desktop.
Getting Name Capitals in JavaScript
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
const splitWords = phrase => phrase.split(' ') | |
const firstLetter = word => word.charAt(0) | |
const lastLetter = word => word.charAt(word.length - 1) | |
const initialLetter = words => words | |
.map(word => word.charAt(0)) | |
.join('') | |
const firstAndLastLetter = word => [ | |
firstLetter(word), | |
lastLetter(word) | |
].join('') | |
const getNameCapitals = name => firstAndLastLetter( | |
initialLetter( | |
splitWords(name) | |
) | |
) | |
getNameCapitals('Isac Fadoni Leite') // IL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment