Mark As Completed Discussion

Let's test your knowledge. Click the correct answer from the options.

What would be the output for the following code?

JAVASCRIPT
1const intArr = [3,10,25,1,7]
2function filterArr(arr) {
3    const newArray = [];
4    return function greaterThan(m){
5        for(let i=0; i<arr.length; i++){
6            if(arr[i] > m){
7            newArray.push(arr[i]);
8            }
9        }
10        console.log("Elements that are greater than m = "+ m + " are: "+ newArray);
11    }
12}
13filterArr(intArr)(9);

A. Elements that are greater than m = 9 are: 10,25

B. Elements that are greater than m = 10 are: 11,26

C. Elements that are greater than m = 9 are: 9,25

D. None of the above.

Click the option that best answers the question.

  • A
  • B
  • C
  • D