Skip to content

Instantly share code, notes, and snippets.

@gdyrrahitis
Created July 10, 2019 19:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gdyrrahitis/d516f20ecd5a2405fc1a9da805b3f6b4 to your computer and use it in GitHub Desktop.
Save gdyrrahitis/d516f20ecd5a2405fc1a9da805b3f6b4 to your computer and use it in GitHub Desktop.
const splitCharacters = (str) => str.split('');
const splitWords = (str) => str.split(' ');
const combineAllCharacters = (str) => str.join('');
const filter = (fn) => (array) => array.filter(fn);
const map = (fn) => (array) => array.map(fn);
const append = (text) => (value) => value + text;
const removeTheLetter = (letter) => (sentence) =>
sentence
|> splitCharacters
|> filter(c => c !== letter)
|> combineAllCharacters;
const makeLetterUpperCase = (letter) => (sentence) =>
sentence
|> splitCharacters
|> map(c => c === letter ? c.toUpperCase() : c)
|> combineAllCharacters;
const removeWordsWithLessThanFourLetters = (sentence) =>
sentence
|> splitWords
|> filter(word => word.length > 4 )
|> combineAllCharacters;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment