/**
* Created by Ashish Patel
* Copyright © 2018 ashish.me
* ashishsushilpatel@gmail.com
*/
function findElement(arr, func) {
let num = 0;
for(let i = 0; i < arr.length; i++){
num = arr[i];
if(func(num)){
return num;
}
}
return undefined;
}
findElement([1, 2, 3, 4], num => num % 2 === 0);
Created 2019-11-24T04:53:20+05:30 · Edit