1// create composite functions
2const composite = (...args) => (initialArg) => args.reduceRight((acc, fn) => fn(acc), initialArg);
3
4const sqrt = (value) => Math.sqrt(value);
5const double = (value) => 2 * value;
6
7const newFunc = composite(sqrt, double);
8
9// ( 32 * 2 ) ** 0.5
10let result = newFunc(32);
11console.log(result); // 8