📜  随机数javascript代码示例

📅  最后修改于: 2022-03-11 15:04:07.885000             🧑  作者: Mango

代码示例6
function uniqueNumber(count) {
  let defaultNumber = 4413277523420
  let convertToArray = defaultNumber.toString().split("")
  let sliceNumber = convertToArray.slice(0, count)
  let randomNumber = Math.floor((Math.random() * +sliceNumber.join("")));
  
  if  (randomNumber.toString().split("").length < count) {
      randomNumber = Math.abs(randomNumber - +sliceNumber.join(""))
  }
 
  return randomNumber
}