Get your own website Result Size: 625 x 565
x
 
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Arrays</h1>
<h2>The every() Method</h2>
<p>The every() method returns true if every element in an array pass a function test.</p>
<p>Click the button to check if every element in the array has a value above this number:</p>
<p><input type="number" id="ageToCheck" value="18"></p>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<script>
// Create an Array
const ages = [32, 33, 12, 40];
// Create a Test Function
function checkAge(age) {
  return age > document.getElementById("ageToCheck").value;
}
// Displau check result
function myFunction() {
  document.getElementById("demo").innerHTML = ages.every(checkAge);
}
</script>
</body>
</html>