Answered step by step
Verified Expert Solution
Question
1 Approved Answer
**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 94Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started