js生成随机数


//生成n以内的随机数
function getRandom(n){
        return Math.floor(Math.random()*n+1)
}

//生成1000以内的随机数
alert(getRandom(1000));

 

posted @ 2015-01-22 10:39  RY一步一个脚印  阅读(194)  评论(0编辑  收藏  举报