编写一个函数实现1~9的随机数

编写一个函数实现1~9的随机数

 //编写一个函数实现1~9的随机数
    var a=Math.floor(Math.random()*10);
    document.write(a);
    //floor(x)对x进行下舍,通过使用Math对象的random()方法,生成指定范围的数

//编写一个函数实现1~9的随机数
var a=Math.floor(Math.random()*10);
document.write(a);
//floor(x)对x进行下舍,通过使用Math对象的random()方法,生成指定范围的数

你可能感兴趣的:(前端,javascript,html5)