function composition - 05

Function composition : 

Function composition is a mechanism by which we can combine multiple functions into a single complicated higher-order function. Here the result will come or move from right to left.


const upperCase = (replaceWord) => { return replaceWord.map( (revWord) => `${revWord[0].toUpperCase()}${revWord.substr(1)}` ); }; const joinText = (arr) => { return arr.join(" "); }; const result = (text) => { return joinText(upperCase(replaceWord(words(text)))); }; const text = "My name is mozahedul islam. and I wanna be a great programmer in the world."; console.log(result(text));



Post a Comment

Previous Post Next Post