June 5, 2023
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
andc
- Initialize three variables
a, b
andc
with value of stringa = [5, 9, 3, 13, 18, 21], b = a.find(function (c)
andc > 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
by : Suhel Akhtar
Quick Summary:
JavaScript Array find() method