javascript-猜数字


需求
从代码角度分析
转换成代码

Math.random() : generates a random decimal number between 0 and 1.

Math.floor():   rounds the number passed to it down to the nearest whole number. 比它小的最接近的整数。

console.log(Math.floor(5.95));
// expected output: 5

console.log(Math.floor(5.05));
// expected output: 5

console.log(Math.floor(5));
// expected output: 5

console.log(Math.floor(-5.05));
// expected output: -6



阅读量: 459
发布于:
修改于: