【发布时间】:2018-11-06 05:17:47
【问题描述】:
您好,我正在制作音量计算器,但似乎无法在屏幕上显示音量。发出警报会解决这个问题吗?这个任务要求我使用匿名函数,所以我很难让函数运行。
HTML
<body>
<h3> Calculate the Volume of a Sphere <h3>
<label for="radius">Radius </label>
<input id="radius" name="radius" required>
</input>
<button id="calc" onclick=sphereVol> calculate </button>
JavaScript
var sphereVol = function(radius){
var c = (4/3) * Math.PI * Math.pow(radius, 3);
return c;
}
【问题讨论】:
-
您需要从函数的输入中读取半径值,然后提醒音量或将其打印在屏幕上。尝试寻找方法。有很多资源可用于执行此操作。尽管如此,如果你被困住了,你可以随时带着你尝试过的任何东西回到这里并获得一些帮助。
标签: javascript calculator volume