Skip to content

Instantly share code, notes, and snippets.

@MeetMartin
Last active October 18, 2020 22:23
Show Gist options
  • Select an option

  • Save MeetMartin/27ba6d779deb869cf5f46a386998ec68 to your computer and use it in GitHub Desktop.

Select an option

Save MeetMartin/27ba6d779deb869cf5f46a386998ec68 to your computer and use it in GitHub Desktop.
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