x
1
2
<html>
3
<body>
4
5
<h2>JavaScript Array.findIndex()</h2>
6
<script>
7
const numbers = [4, 9, 16, 25, 29];
8
9
document.write("First number over 18 has index " + numbers.findIndex(myFunction));
10
function myFunction(value, index, array) {
11
return value > 18;
12
}
13
</script>
14
15
</body>
16
</html>