运行 ❯
获取您
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
转到 Spaces
<!DOCTYPE html> <html> <body> <h1>JavaScript Math</h1> <h2>The Math.round() Method</h2> <p>Math.round() rounds a number to the nearest integer:</p> <p id="demo"></p> <script> let a = Math.round(2.60); let b = Math.round(2.50); let c = Math.round(2.49); let d = Math.round(-2.60); let e = Math.round(-2.50); let f = Math.round(-2.49); document.getElementById("demo").innerHTML = a + "<br>" + b + "<br>" + c + "<br>" + d + "<br>" + e + "<br>" + f; </script> </body> </html>