Try this exercise. Click the correct answer from the options.
What would be the output of the following code?
JAVASCRIPT
1const intArr = [3,10,25,2,7]
2function customForEach(arr,fn){
3 for(let i=0; i<arr.length; i++){
4 fn(arr[i] % 2 == 0, () => {
5 console.log(arr[i], "is even");
6 });
7 }
8}
9function unless(test, then) {
10 if (test) then();
11}
12
13customForEach(intArr,unless);
A. 10 is even 2 is even
B. 12 is even 10 is even
C. 7 is odd 3 is odd
D. `None of the above.
Click the option that best answers the question.
- A
- B
- C
- D