Tell us what’s happening:
I am trying to understand what is this variable doing? is this variable mandatory or part of a for loop?
let num = 0;
I understand I need to do a foot loop to look through the array AND the function.
Your code so far
function findElement(arr, func) {
let num = 0;
return num;
}
findElement([1, 2, 3, 4], num => num % 2 === 0);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36
.
Challenge: Finders Keepers
Link to the challenge:
Learn to code. Build projects. Earn certifications.Since 2015, 40,000 graduates have gotten jobs at tech companies including Google, Apple, Amazon, and Microsoft.
I don’t know why it’s there, if you don’t find it useful delete it, and go with your own idea
It’s what I would do
1 Like
It is a bit confusing, but yes will do that, thanks!
How would you advise to pass the first element in the array that passes a truth test?
I understand is an evaluation but using the === would do the job?
Syntax is the issue
first you need to be sure you understand how to make the element undergo the truth test
and it depends what you are comparing
1 Like
I found on Stackoverflow that someone asked about this challenge so I will use .filter to make sure the element passes the test in the function