I have this:
const array1 = [12, 5, 8, 130, 44];
var check = array1.find((element, b) => b);
console.log(check);
Output is coming as 5 rather than 12 why?
The find() method returns the value of the first element in the provided array that satisfies the provided testing function. If no values satisfy the testing function, undefined is returned.
const array1 = [5, 12, 8, 130, 44];
const found = array1.find(n=>n>20); console.log(found);
this will return 130 because n is greater than 20 we specified here
const array1 = [3,4,5,8,1]
const found = array1.find(n=>n>3)
will return 4
this will be correct one
const array1 = [12,5,8, 130, 44];
var check=array1.find(b => b>10 ); console.log(check);
and the error is because you are not targeting the correct element
The find() method returns the value of the first element in the provided array that satisfies the provided testing function. If no values satisfy the testing function, undefined is returned.