How to use JavaScript Array find()
Array find
On this page
Array find() Method
Program to use JavaScript Array find() method
let a = [5, 9, 3, 13, 18, 21];
let b = a.find(function (c) {
return c > 9;
});
console.log(b);
Output
13
Steps Description
- Declare three variables a, b and c
- Initialize three variables a, b and c with value of string a = [5, 9, 3, 13, 18, 21], b = a.find(function (c) and c > 9
- Array find() method find array element if any statement element matches then return its value
- The value of b variable is displayed with the help of console.log inbuilt function