Array findIndex in JavaScript
Level 275 keystrokes
findIndex() returns the index of the first element that satisfies the provided testing function.
JavaScript code
// Create an array of numbers1const nums = [5, 12, 8, 130, 44];// findIndex() returns index of first element > 10 (returns 1 for 12)2console.log(nums.findIndex(n => n > 10));Output
1
Practice typing this code. Results are not recorded in the rankings.
Symbols in this code
The symbols you type in this JavaScript code and how often they appear.
,× 4;× 2.× 2(× 2)× 2=× 2>× 2[× 1]× 1