findIndex()
can anyone explain findIndex in js how is the workflow in brief.
2 Replies
.findIndex()
looks inside array1
, and for each element, it looks if element > 13
, if it is, it returns its indexI strongly suggest looking using MDN for referencing JavaScript documentation: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex
MDN Web Docs
Array.prototype.findIndex() - JavaScript | MDN
The findIndex() method of Array instances returns the index of the first element in an array that satisfies the provided testing function.
If no elements satisfy the testing function, -1 is returned.