Question: Writing two functions as the following instruction map & filter by using JavaScript . Input [2,7,6,9,1,4] *Exercise 2 Higher Order Functions * Let's get some

Writing two functions as the following instruction map & filter by using JavaScript.

Input [2,7,6,9,1,4]Writing two functions as the following instruction map & filter by using

*Exercise 2 Higher Order Functions * Let's get some practice with JavaScript functions by implementing some variants * of the higher-order functions * Note: JavaScript (since its fifth edition) has built-in map, filter, and reduce functions * This is great because it means you can use them in the other exercises and your subsequent homeworks ! However, I have disabled them for this exercise, so you do have to write the functions yourself * First, let's implement map. Map takes in * two arguments-an array to perform the mapping on, and the mapping function. * It applies the mapping function to all elements in the array and returns an array of results var map-function (array, mappingFunction) /1 Your code goes here *Next, let's implement filter. Filter takes in * two arguments - an array to filter, and a filtering function. It returns a list of all * elements of the array such that filterFunction (element) ue. var filter-function (array, filterFunction) /1 Your code goes here *Exercise 2 Higher Order Functions * Let's get some practice with JavaScript functions by implementing some variants * of the higher-order functions * Note: JavaScript (since its fifth edition) has built-in map, filter, and reduce functions * This is great because it means you can use them in the other exercises and your subsequent homeworks ! However, I have disabled them for this exercise, so you do have to write the functions yourself * First, let's implement map. Map takes in * two arguments-an array to perform the mapping on, and the mapping function. * It applies the mapping function to all elements in the array and returns an array of results var map-function (array, mappingFunction) /1 Your code goes here *Next, let's implement filter. Filter takes in * two arguments - an array to filter, and a filtering function. It returns a list of all * elements of the array such that filterFunction (element) ue. var filter-function (array, filterFunction) /1 Your code goes here

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!