其实仅仅是因为想不出车牌号,干脆写一个函数随机生成算了...

 

问题描述

批量生成 两个字母 + 三个数字 的随机数

 

解决方案

function getRandomByStr(l = 3, s) {
    if (typeof s !== 'string') { return }
    var len = +l;
var chars = ''; while (len--) { chars += s[parseInt(Math.random() * s.length, 10)]; } return chars; } function getPlate(total = 9) { var en = 'QWERTYUIOPASDFGHJKLZXCVBNM'; var num = '1234567890'; var len = +total; while (len--) { console.log(`车牌号 ${total - len}:`, getRandomByStr(2, en) + getRandomByStr(3, num)); } } getPlate();

 

相关文章:

  • 2021-08-06
  • 2021-09-19
  • 2021-12-26
  • 2022-12-23
  • 2022-12-23
  • 2021-12-12
  • 2021-06-30
猜你喜欢
  • 2021-04-23
  • 2022-12-23
  • 2021-08-06
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-11
相关资源
相似解决方案