04-04-2023, 08:12 AM
(This post was last modified: 04-04-2023, 08:12 AM by Qomplainerz.)
The HTML part between the <body></body> tags looks like this:
The JavaScript part looks like this:
Code:
<p>Click "Test" to return the value of the first element in the array that has a value above this number:</p>
<p><input type="number" id="ageToCheck" value="18"></p>
<button onclick="myFunction()">Test</button>
<p id="demo"></p>
The JavaScript part looks like this:
Code:
const ages = [4, 12, 16, 20];
function checkAge(age)
{
return age > document.getElementById("ageToCheck").value;
}
function myFunction()
{
document.getElementById("demo").innerHTML = ages.find(checkAge);
}
Also follow me on Youtube for videos about video games:
https://www.youtube.com/channel/UCxfkGVU...2mQ/videos
https://www.youtube.com/channel/UCxfkGVU...2mQ/videos