mirror of https://github.com/01-edu/public.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
davhojt
61ab6ec47b
|
2 years ago | |
---|---|---|
.. | ||
README.md | 2 years ago |
README.md
Using Reduce
Instructions
Create the following functions:
Your solutions must use
reduce
.
-
adder
: accepts an array of numbers, and returns the sum as anumber
. -
sumOrMul
: accepts an array of numbers and adds or multiplies its elements depending on whether the element is odd or even. Even = multiply. Odd = add. -
funcExec
: accepts an array of functions and executes them usingreduce
, returning the result.
Each function may accept an optional argument, which should be the initial value for the function's execution.
Example:
sumOrMul([1, 2, 3, 5, 8], 5) // (((((5 + 1) * 2) + 3) + 5) * 8) -> 160