第65关:数学天才 (Math) 📐

XP: 0/100
🦸‍♂️

JS队长

Math 对象是一个静态工具库,里面装满了数学常数和函数。

常用:Math.round() (四舍五入), Math.floor() (向下取整), Math.ceil() (向上取整)。

🐛

Bug捣蛋鬼

我要随机制造混乱!🎲

🦸‍♂️

JS队长

Math.random() 可以生成 0 到 1 之间的随机小数。

配合取整函数,我们可以做骰子、抽奖等功能!

🎮 幸运骰子

点击按钮掷骰子 (1-6)。我们需要用 Math.floor(Math.random() * 6) + 1

🎲
?