А
Size: a a a
А
В
В
В
В
В
t
В
DE
L
В
В
p
function flow(input, funcArray) {
for (let x of funcArray) {
input = x(input)
}
return input;
}
// functions
function multiplyBy2(num) { return num * 2; }
function add7(num) { return num + 7; }
function modulo4(num) { return num % 4; }
function subtract10(num) { return num - 10; }
//array of functions
const arrayOfFunctions = [multiplyBy2, add7, modulo4, subtract10];
console.log(flow(2, arrayOfFunctions)); // -> -7
function flow(input, funcArray) {
if(funcArray.length === 0) return input;
const output = funcArray[0](input);
return flow(output, funcArray.slice(1));
}
S
function flow(input, funcArray) {
if(funcArray.length === 0) return input;
const output = funcArray[0](input);
return flow(output, funcArray.slice(1));
}
А
В
p
В