Math.random() 會回傳一個 0 到 1 之間的隨機小數,包含 0,但不包含 1。
Math.random()
若要產生指定範圍的整數,可搭配 Math.floor() 與乘法運算。
這個方法常用於抽獎、隨機排序、遊戲邏輯與測試資料生成。