.find()

The .find() array method returns the first element in the array that satifies the given function.

Syntax

array.find((element) => element < 5);

If none of the elements in the array satisfy the function, undefined is returned.

Example

Finding the first temperature that’s over 90 °F:

const temperature = [72, 87, 92, 90, 85, 88, 81];
const hot = temperature.find((element) => element >= 90);
console.log(hot);
// Output: 92

Codebyte Example

Interested in helping build Docs? Read the Contribution Guide or share your feedback.

Learn JavaScript on Codecademy