Last active
October 18, 2020 22:23
-
-
Save MeetMartin/27ba6d779deb869cf5f46a386998ec68 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
| import {trim, upperCaseOf, lengthOf, lastLetterOf, includes, compose} from '@7urtle/lambda'; | |
| const endsWithPunctuation = input => | |
| includes(lastLetterOf(input))('.?,!'); | |
| const replacePunctuationWithExclamation = input => | |
| substr(lengthOf(input) - 1)(0)(input) + '!'; | |
| const addExclamationMark = input => | |
| endsWithPunctuation(input) | |
| ? replacePunctuationWithExclamation(input) | |
| : input + '!'; | |
| const shout = compose(addExclamationMark, upperCaseOf, trim); | |
| shout(" Don't forget to feed the turtle."); | |
| // => DON'T FORGET TO FEED THE TURTLE! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment