Last active
April 10, 2016 02:16
-
-
Save johntran/a96385d23d7a2c83667bfaa4ce82ec87 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
// basically it asks to create a function that reverse the whole string without reverse the positions of the words. | |
// "Three Blind mice" | |
// "eerhT dnilB ecim" | |
var stringToArray = function (str) { | |
return str.split(' ') | |
} | |
// ['Three', 'Blind', 'mice'] | |
var reverseElementsInArray = function (arr) { | |
return arr.map(function(element) { | |
return element.split('') | |
.reverse() | |
.join('') | |
}) | |
} | |
// ['eerhT', 'dnilB', 'ecim'] | |
var arrayToSentence = function (arr) { | |
return arr.join(' ') | |
} | |
// "eerhT dnilB ecim" | |
var oneLiner = function (str) { | |
return str.split(' ') | |
.map(function(element) { | |
return element.split('') | |
.reverse() | |
.join('') | |
}) | |
.join(' ') | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment