JS案例:通过常量PI求圆的周长

来自CloudWiki
跳转至: 导航搜索
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>求圆的周长案例示例</title>
</head><body>
<script type="text/javascript">
var r=2.5; //声明圆的半径r
const p=Math.PI;
var c=p*2*r; //声明圆的周长并求出其值
document.write("半径为2.5的圆的周长为:"+ c);
</script>
</body></html>