How to find the first element in int array that pass a test in JavaScript

1 Answer

0 votes
const marks = [78, 92, 100, 86, 91];
 
function checkMark(mark) {
    return mark >= 80;
} 
 
console.log(marks.find(checkMark));
 
 
/*
 
run:
 
92
 
*/

 



answered Apr 5, 2017 by avibootz
edited Nov 3, 2024 by avibootz
...