.findIndex() Operator

Take a look at this code:

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

const foundAnimal = animals.findIndex(animal => {
return animal === ‘elephant’;

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

the result is 3 because the third because the word at index 3 begins with ‘s’.

How would I find the first character of the second word beginning with ‘s’?

Why would you want that? Because that also means you might need to use a different approach altogether.

you could make a variable (for example first), which will hold a Boolean value. Then use a for loop, then check if the first letter is s and what the value of the first variable is

you could also use indexOf, depending on your use case, this functions allows to specify starting position.

If a word starts with s then its first character is s …
Maybe you meant that you want to find all locations of such words

In which case, you could start with all locations, and filter by whether the corresponding value starts with s

how would I filter it to find each word?