Find the index of the first animal that starts with the letter 's'.

PHOTO EMBED

Tue Oct 05 2021 13:00:40 GMT+0000 (Coordinated Universal Time)

Saved by @ianvalentino #javascript #method

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

const startsWithS = animals.findIndex(animal => {
  return animal[0] === 's' ? true : false;
});

console.log(startsWithS);
content_copyCOPY

ITERATORS The .findIndex() Method

https://www.codecademy.com/courses/introduction-to-javascript/lessons/javascript-iterators/exercises/find-index