執行 ❯
建立您
自己的
網站
×
更改方向
儲存程式碼
更改主題,深色/淺色
前往 Spaces
<!DOCTYPE html> <html> <body> <h2>JavaScript Arrays</h2> <p>Click the button to test if any array elements has a higher value than the input.</p> <p>Input: <input type="number" id="toCheck" value="15"></p> <button onclick="myFunction()">Test</button> <p>Values higher: <span id="demo"></span></p> <script> const numbers = [4, 12, 16, 20]; function checkValue(x) { return x > document.getElementById("toCheck").value; } function myFunction() { document.getElementById("demo").innerHTML = numbers.some(checkValue); } </script> </body> </html>