# Exercises for Session 4 1. Convert this function declaration into an arrow function: ```javascript function myFunc(arg1, arg2, ...rest) { // ... return something; } ``` 1. Convert the arrow function passed as reducer into a regular function statement: ```javascript arr.reduce((acc, current) => acc + current, 0); ``` 1. Given this function ```javascript const sum = (...operands) => operands.reduce((acc, current) => acc + current, 0); ``` and this input ```javascript const summands = [3.2, 1.1, -2, 4.32]; ``` call the function using the given inputs and making use of the spread operator. 1. Given the following object: ```javascript const stats = { points: 234, rebounds: 342, assists: 381, }; ``` Create an entries array and print the contents of the object to the console with the format `<stat>: <value>`. Make use of destructuring when calling the function that prints the message to the console. 1. Create a function that: 1. Has the name `getStatsSum`. 1. Takes a `stats` object as the one described above as only argument. 1. Makes use of object destructuring in the argument declaration. 1. Returns the sum of the three values in the object. 1. Create a function that takes any number of number arguments (including 0 arguments) and returns [their multiplication](https://en.wikipedia.org/wiki/Multiplication#Product_of_a_sequence). 1. Create a function that complies with the following specification: ```javascript /** * Composes functions * * E.g. given the functions f1, f2, f3, * compose([f1, f2, f3], f1Input) === f3(f2(f1(f1Input))) * * @param {Function[]} functionArray: an array containing the functions that * will be composed from left to right. * @param {any} initialInput: the input that the first function to be applied * takes. * @return {any} The return value will be the result of the composition. */ const compose = (functionArray, initialInput) => { // statements }; ``` _**Hint**: use recursion or, alternatively, use a reducer_. 1. Refactor the previous function using an alternative approach. 1. Refactor the previous function so that it takes the arguments like this: ```javascript compose(...functionArray)(initialInput) ``` _**Hint**: use currying_ 1. Write the necessary code to log an array of objects with the structure `{ title: <titleValue>, url: <urlValue> }`, retrieving _the actual data_ from the `data.children` array found [here](https://www.reddit.com/r/javascript.json). - Hints: - Use the [`fetch`](https://devdocs.io/dom/fetch) helper as explained during the session. - Use the [`<response>.json()`](https://devdocs.io/dom/response/json) method to parse the response to an object. - Download [this HTML file](https://gist.github.com/lualparedes/7e1f2a320078c88e7638c283f4a29039), place the code inside the `<script>` element and open the file using any browser to execute the code and see the result in the browser's console.