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

4 years ago
## Using Reduce
### Instructions
4 years ago
Create the following functions:
> Your solutions **must** use `reduce`.
4 years ago
- `adder`: accepts an array of numbers, and returns the sum as a `number`.
4 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.
4 years ago
- `funcExec`: accepts an array of functions and executes them using `reduce`, returning the result.
4 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
```
4 years ago
### Notions
- [Array.prototype.reduce](https://devdocs.io/javascript/global_objects/array/reduce)