Skip to content

Instantly share code, notes, and snippets.

@gdyrrahitis
Created July 10, 2019 20:29
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/9f4eacdfc0fdd8c299a22a6968eec657 to your computer and use it in GitHub Desktop.
Save gdyrrahitis/9f4eacdfc0fdd8c299a22a6968eec657 to your computer and use it in GitHub Desktop.
const append = (text) => (value) => value + text;
const removeTheLetter = (letter) => (sentence) =>
sentence
.split('')
.filter(c => c !== letter)
.join('');
const makeLetterUpperCase = (letter) => (sentence) =>
sentence.split('')
.map(c => c === letter ? c.toUpperCase() : c)
.join('');
const removeWordsWithLessThanFourLetters = (sentence) =>
sentence
.split(' ')
.filter(word => word.length > 4)
.join(' ');
const phrase = 'Welcome';
const result = removeWordsWithLessThanFourLetters(
makeLetterUpperCase('e')(
makeLetterUpperCase('a')(
makeLetterUpperCase('o')(
removeTheLetter('i')(
append(' pipelining')(
append(' I hope you like')(
append(' Functional Programming')(
append(' to')(phrase)
)
)
)
)
)
)
)
);
console.log(result);
// prints: WElcOmE FunctOnAl PrOgrAmmng ppElnng
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment