Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

a quick introduction to pipe and compose javascript

// pipe can be used to streamline the chaining of method calls
// Reference: https://www.freecodecamp.org/news/pipe-and-compose-in-javascript-5b04004ac937/
getName = (person) => person.name; // first method
uppercase = (string) => string.toUpperCase(); // second method
get6Characters = (string) => string.substring(0, 6); // third method
reverse = (string) =>
  string
    .split('')
    .reverse()
    .join(''); // fourth method
pipe(
  getName,
  uppercase,
  get6Characters,
  reverse
)({ name: 'Buckethead' }); // create a to do list of functions
// Output: 'TEKCUB'
Source by www.freecodecamp.org #
 
PREVIOUS NEXT
Tagged: #quick #introduction #pipe #compose #javascript
ADD COMMENT
Topic
Name
8+7 =