The .findIndex() Method

PHOTO EMBED

Mon Jul 18 2022 20:56:21 GMT+0000 (Coordinated Universal Time)

Saved by @cruz #javascript

const animals = ['hippo', 'tiger', 'lion', 'seal', 'cheetah', 'monkey', 'salamander', 'elephant'];


const foundAnimal = animals.findIndex(animals => {
  return animals ==='elephant';
});
console.log(foundAnimal);

const startsWithS = animals.findIndex(animals => {
  return animals[0] ==='s';
});

console.log(startsWithS);
content_copyCOPY