Message from JavaScript discussions

November 2017

— Sure

— 

function compose(input, ...functions) {
functions.forEach(func => input = func(input));
return input;
}

— Aaaaaa

— ASSIGNMENT

— Why don't you reduce m8

— It gets the job done

— Also, I thought the point of compose was to create a new function?

— 

function compose(...fns) {
return input => fns.reduce((val, fn) => fn(val), input);
}

— How is this not nicer?

— Idk

— Here's how I use mine

— 

function randStr(bits = 16) {
compose((1 + Math.random()) * 0x10000,
Math.floor,
int => int.toString(bits),
str => str.substring(1)
);
}

Message permanent page