Answered step by step
Verified Expert Solution
Link Copied!

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) :

*******************************************************************************************************************************************************************

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Making Databases Work The Pragmatic Wisdom Of Michael Stonebraker

Authors: Michael L. Brodie

1st Edition

1947487167, 978-1947487161

More Books

Students also viewed these Databases questions

Question

How could a quality philosophy be applied to a supply department?

Answered: 1 week ago

Question

Write a short note on rancidity and corrosiveness.

Answered: 1 week ago