Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

react array find index

//The findIndex() method returns the index of the first element 
//in the array that satisfies the provided testing function.
//Otherwise, it returns -1, indicating that no element passed the test.
const array1 = [5, 12, 8, 130, 44];

const isLargeNumber = (element) => element > 13;

console.log(array1.findIndex(isLargeNumber));
// expected output: 3
 
PREVIOUS NEXT
Tagged: #react #array #find #index
ADD COMMENT
Topic
Name
2+6 =