运行 ❯
获取您
的
网站
×
更改方向
保存代码
更改主题,暗/亮
前往 Spaces
<!DOCTYPE html> <html> <body> <h1>JavaScript Math</h1> <h2>The Math.sin() Method</h2> <p>Math.sin() returns the sine of an angel given in radians.</p> <p>To use degrees, convert the degrees to radians first:</p> <p id="demo"></p> <script> document.getElementById("demo").innerHTML = "The sine of 0 degrees is: " + sine(0) + "<br>" + "The sine of 30 degrees is: " + sine(30) + "<br>" + "The sine of 90 degrees is: " + sine(90) + "<br>" + "The sine of 150 degrees is: " + sine(150) + "<br>" + "The sine of 180 degrees is: " + sine(180) + "<br>" + "The sine of 210 degrees is: " + sine(210) + "<br>" + "The sine of 270 degrees is: " + sine(270) + "<br>" + "The sine of 360 degrees is: " + sine(360); function sine(degree) { // radians = degrees * PI / 180 let x = Math.sin(degree * Math.PI / 180); return x.toFixed(2); } </script> </body> </html>