Skip to content

Instantly share code, notes, and snippets.

@gdyrrahitis

gdyrrahitis/pipeline.js Secret

Created Jul 10, 2019
Embed
What would you like to do?
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
You can’t perform that action at this time.