运行 ❯
获取您
自身
的网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!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 id="demo"></p> <script> // Create an Array const ages = [32, 33, 16, 40]; // Function to Run for every Element function checkAge(age) { return age > 18; } document.getElementById("demo").innerHTML = "Is every element over 18? " + ages.every(checkAge); </script> </body> </html>