Whenever you are confused about what the challenge is asking from you it will help to look at the test cases.
In the first test cases we have an array like this [1, 3, 5, 8, 9, 10] and a function as the second argument like this function(num) { return num % 2 === 0; }
Our task is to return the first element in the array that passes this test num % 2 === 0.
So what is the first number in the list that passes the test?
It is 8 right? We can check by substituting num for 8.
8 % 2 === 0
translates to
8 divided by 2 gives us a remainder of 0.
Your job is to create a function that returns the first element in the array that passes the test from the function argument. If none of the elements pass the test then your function needs to return undefined.
Tell us what’s happening:
I have completed the half of the challenge. The other half I got stuck of it
What are the mistakes on my code. What is the steps to correct my mistakes and return as below:
Instead of using the func argument, you seem to have just deleted it. Your current code returns the first array element if it is divisible by 2. Otherwise, it returns undefined.