首页 > 代码库 > 舍入数字和烝骰子事件的实现

舍入数字和烝骰子事件的实现

image

<script type="text/javascript">
var num=prompt("Please input a number:","");
document.write("Round:"+Math.round(num));
document.write("<br>");
document.write("Ceil:"+Math.ceil(num));
document.write("<br>");
document.write("Floor:"+Math.floor(num));
</script>

 

<script type="text/javascript">
var diceThrow=Math.round(Math.random()*5)+1;
document.write("You threw a "+diceThrow);
</script>

舍入数字和烝骰子事件的实现