Created
January 14, 2018 06:59
-
-
Save pratyushcrd/e5babd37b54254dc59b4e5d376c9c03e 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
// Reverse only the letters of words in a sentence | |
// A helper function to reverse words | |
const reverseWord = str => str.split('').reverse().join('') | |
// Actual function | |
const reverseLettersInSentence = sentence => sentence | |
.split(' ') | |
.map(reverseWord) | |
.join(' ') | |
// Execution | |
reverseLettersInSentence('Hello World') | |
// Output | |
"olleH dlroW" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment