Last active
June 30, 2017 10:22
-
-
Save kutyel/ead4eb84ca91859e947bca37f1a78ba5 to your computer and use it in GitHub Desktop.
Translate to badger language using native JavaScript functional programming (without Ramda.js)
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
/** | |
* Translate a sentence to badger language, | |
* applying the following transformations: | |
* | |
* 1) Reverse letters | |
* 2) Capitalize first letter | |
* 3) Reverse words | |
* | |
* Sample input: "Thank you" | |
* Sample output: "Uoy Knaht" | |
* | |
*/ | |
const reverse = x => x | |
.split('') | |
.reverse() | |
.join('') | |
const capitalizeFirstLetter = x => x | |
.charAt(0) | |
.toUpperCase() | |
.concat(x.slice(1)) | |
const translateToBadger = words => words | |
.split(' ') | |
.reverse() | |
.map(reverse) | |
.map(capitalizeFirstLetter) | |
.join(' ') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment