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.
|
|
|
## Using Reduce
|
|
|
|
|
|
|
|
### Instructions
|
|
|
|
|
|
|
|
Create three functions :
|
|
|
|
- `adder` that receives an array and adds its elements.
|
|
|
|
|
|
|
|
- `sumOrMul` that receives an array and adds or multiplies its elements
|
|
|
|
depending on whether the element is an odd or an even number.
|
|
|
|
|
|
|
|
- `funcExec` that receives an array of functions and executes them.
|
|
|
|
|
|
|
|
All functions may or may not receive an extra argument that should be the
|
|
|
|
initial value for the functions execution.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
```js
|
|
|
|
sumOrMul([1, 2, 3, 4], 5)
|
|
|
|
// -> (((5 + 1) * 2) + 3) * 4
|
|
|
|
// -> 60
|
|
|
|
````
|
|
|
|
|
|
|
|
#### Special instruction
|
|
|
|
|
|
|
|
The goal of this exercise is to learn to use `reduce`, as such all your
|
|
|
|
solution **MUST** use `reduce`
|
|
|
|
|
|
|
|
|
|
|
|
### Notions
|
|
|
|
|
|
|
|
- [devdocs.io/javascript/global_objects/array/reduce](https://devdocs.io/javascript/global_objects/array/reduce)
|