<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Arrays</h1>
<h2>findLastIndex()</h2>
<p>Click "Test" to return the index of the last array element that has a value above this number:</p>
<p><input type="number" id="toCheck" value="18"></p>
<button onclick="myFunction()">Test</button>
<p id="demo"></p>
<script>
const numbers = [4, 12, 16, 20];
function checkValue(x) {
return x > document.getElementById("toCheck").value;
}
function myFunction() {
document.getElementById("demo").innerHTML = numbers.findLastIndex(checkValue);
}
</script>
<p>findLastIndex() is not supported in Internet Explorer.</p>
</body>
</html>