Question: **using JavaScript (nodeJS) : ******************************************************************************************************************************************************************* Exercise 3 - ES6 - Higher-Order Functions 1. let matrix = [ [2, 3], [34, 89], [55, 101, 34], [34,
**using JavaScript (nodeJS) :
*******************************************************************************************************************************************************************

Exercise 3 - ES6 - Higher-Order Functions 1. let matrix = [ [2, 3], [34, 89], [55, 101, 34], [34, 89, 34, 99]]; Use the above array and Implement and test the following functions: flatten: gets a matrix (i.e., array of arrays) and returns a single dimensional flat array. max: gets an array and returns its maximum value. Use reduce function. > sort: gets an array and returns a sorted array in descending order (from big to small). square: gets an array and returns an array with squared values. average: gets an array and returns its average. > removeDuplicate: gets an array and returns an array without duplicate elements. Filter : Find the sum of all the number in the array that are greater than 40. You should write everything as one single statement. Use the following matrix to test your work. Expected output: Original array: [[ 2, 3 ], [ 34, 89 ], [ 55, 101, 34 ], [ 34, 89, 34, 99 ] ] Flattened: [ 2, 3, 34, 89, 55, 101, 34, 34, 89, 34, 99 ] Max value: 101 Sorted in descending order: [ 101, 99, 89, 89, 55, 34, 34, 34, 34, 3, 2 ] Without duplicate elements: [ 101, 99, 89, 55, 34, 3, 2 ] Sum of unique elements: 574 Square of unique elements: 10201 9801 7921 7921 3025 1156 1156 1156 1156 94
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
