To get first element of a collection that matches iterator function with JavaScript, we use the array find
method.
For instance, we write
const array = [5, 12, 8, 130, 44];
const found = array.find((element) => element > 10);
console.log(found);
to call array.find
with a function that returns the first element in array
that’s bigger than 10.
ASs a result, found
is 12.