TianHero

// alert( Math.round(3.4) );
// 0~1 : Math.round(Math.random());
// 0~10
// alert( Math.round(Math.random()*10) );

// 5~10
// alert( Math.round( Math.random()*5 + 5 ) );

// 10~20
// alert( Math.round( Math.random()*10 + 10 ) );

// 20~100
// alert( Math.round( Math.random()*80 + 20 ) );

// x ~ y
var x = 3;
var y = 49;
// alert( Math.round( Math.random()*(y-x) + x ) );

// 0~x
// alert( Math.round( Math.random()*x) );

// 1~x
alert( Math.ceil( Math.random()*x) );

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-02-22
  • 2021-12-24
猜你喜欢
  • 2021-12-24
  • 2021-12-09
  • 2021-12-24
  • 2022-12-23
  • 2021-12-24
  • 2021-12-24
  • 2021-12-24
相关资源
相似解决方案