js实现随机数和随机数组

//随机数 
  var num = Math.ceil(Math.random() * 3)
  console.log(num);
  //随机数组 
  var a = ['1','2','3','4','5'];
  console.log(a[parseInt(Math.random() * a.length)])

  

posted @ 2020-11-17 17:23  YH丶浩  阅读(494)  评论(0编辑  收藏  举报