Created
February 25, 2019 01:13
-
-
Save okovalov/dffc1e4a412c64b366aa0810e696fb5b to your computer and use it in GitHub Desktop.
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 reverseWords = string => { | |
const wordsArr = string.split(' ') | |
let result = [] | |
wordsArr.forEach(el => { | |
result.push(el.split('').reverse().join('')) | |
}) | |
return result.join(' ') | |
} | |
const string = 'abcd ef gt' | |
const reversed = reverseWords(string) | |
console.log(`reverse of '${string}' is '${reversed}'`) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment