Find first element in an array matching a condition in JavaScript

find

examples/javascript/find_first.js

let animals = ['snake', 'camel', 'etruscan shrew', 'ant', 'hippopotamus', 'giraffe'];
let first = animals.find(a => a.length > 5);
console.log(first);

Author

Gabor Szabo (szabgab) Gabor Szabo