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.

26 lines
752 B

5 years ago
## Using Reduce
### Instructions
5 years ago
Create the following functions:
> Your solutions **must** use `reduce`.
5 years ago
- `adder`: accepts an array of numbers, and returns the sum as a `number`.
5 years ago
- `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.
5 years ago
- `funcExec`: accepts an array of functions and executes them using `reduce`, returning the result.
5 years ago
> Each function may accept an optional argument, which should be the initial value for the function's execution.
#### Example:
```js
sumOrMul([1, 2, 3, 5, 8], 5) // (((((5 + 1) * 2) + 3) + 5) * 8) -> 160
```
5 years ago
### Notions
- [Array.prototype.reduce](https://devdocs.io/javascript/global_objects/array/reduce)