const replaceUnderscoreWithSpace = (value) => value.replace(/_/g, ' ')
const capitalize = (value) =>
value
.split(' ')
.map((val) => val.charAt(0).toUpperCase() + val.slice(1))
.join(' ');
const appendGreeting = (value) => `Hello, ${value}!`
const pipe = (value, ...funcs) => value => funcs.reduce((value, f) => f(value), value)
I`m trying to implement pipe function, but I can`t get how to make it work so it takes param “value” as argument.
Example
const result = pipe(
"john_doe",
replaceUnderscoreWithSpace,
capitalize,
appendGreeting,
);
alert(result); // Hello, John Doe!