JavaScript

June 5, 2023

How to use JavaScript Array find()

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

  1. Declare three variables a, b and c
  2. 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
  3. Array find() method find array element if any statement element matches then return its value
  4. The value of b variable is displayed with the help of console.log inbuilt function

by : Suhel Akhtar

Quick Summary:

JavaScript Array find() method