Use this technique to generate and return a random whole number between 0 and 9.
代码
var randomNumberBetween0and19 = Math.floor(Math.random() * 20);
function randomWholeNum() {
// Only change code below this line.
return Math.floor(Math.random()*10);
}
介绍
生成0到任意区间的随意整数。
方法
生成0到20之间的整数,不包括0和20。
练习
代码
结果显示
来源
https://www.freecodecamp.org/challenges/generate-random-whole-numbers-with-javascript