343,344,345,346影片 財金程式設計346乙班RANDOM,FLOOR,CEIL,ROUND 介紹物件object 344亂數RANDOM無條件捨去小數FLOOR a 輸入整數<input typt="number" min=1 max=1000/> <button onclick="abc()">謝孜妤執行</button> <h3>Math.random()亂數Method方法</h3><p id="demo"></p> <h3>Math.floor()捨去小數Method方法</h3><p id="demo1"></p> <h3>Math.ceil()進位Method方法</h3><p id="demo2"></p> <h3>Math.round()四捨五入Method方法</h3><p id="demo3"></p> <script> function abc(){ let n=document.getElementById("n").value; let x=Math.random()*n; document.getElementById("demo").innerHTML =x; document.getElementById("demo1").innerHTML=Math.floor(x); document.getElementById("demo2").innerHTML=Math.ceil(x); document.getElementById("demo3").innerHTML=Math.round(x);} </script>