opkdealer.blogg.se

Findindex javascript
Findindex javascript





findindex javascript findindex javascript

However, when I run this in the console through node.js, I get the following error message:

findindex javascript

SIndex = animalSlice.findIndex(animal => animal = 's') Find the next animal that starts with s in the animals array. Push the current found animal onto the array sNameAnimals Let sIndex = animals.findIndex(animal => animal = 's') Create a function that finds all animals in the array animals starting with the letter s. Here is the code I have so far: const animals = Then I try to splice the animals array from sIndex + 1, apply findIndex() and then update sIndex with the value returned. findIndex() method to find the first animal name beginning with 's' and save its value to a variable named sIndex. I define an example array called animals and populate it with some strings. and thought I would try to extend one of their ideas to search for all strings within an array that start with the string 's'. I've been working throught the introduction to JavaScript course on Codecademy







Findindex javascript