public/subjects/using-reduce
davhojt 61ab6ec47b docs(using-reduce): correct grammar 2022-06-15 23:34:59 +03:00
..
README.md docs(using-reduce): correct grammar 2022-06-15 23:34:59 +03:00

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 a number.

  • 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 using reduce, 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

Notions