Array.prototype.findIndex makes finding items in arrays easier
takes a compare function, returns the index where it returned true
returns the first position it was found at
returns -1 when nothing was found
the findIndex callback gets the item, index and array as arguments
combined with destructuring complex compares become short
Required Knowledge
- `const` declaration (Block scope)
Related Katas
Array API
array.sort()basicsarray.sort()can take a compare functionarray.shift()(as introduced in ES3)array.push()(as introduced in ES3)Array.from()Array.of()array.fill()array.find()array.findIndex()array.entries()array.keys()array.values()array.includes()array.toReversed()
Difficulty Level
TBD
First Published
4 May 2015
Stats
5 tests to solve