function getPlate(total = 5) { let stateList = '京津冀晋辽吉沪苏浙皖闽琼赣鲁豫鄂湘粤渝川贵云陕甘蒙黑桂藏青宁新' let charList = 'ABCDEFGHJKLMNQPRSTUVWXYZ' let numList = '1234567890' let halfList = [charList, numList] let state = dicingChar(stateList) let city = dicingChar(charList) let sequence = '' while (total--) { sequence += dicingChar(halfList[Math.round(Math.random())]) } console.log(`${state}${city} ${sequence}`) } function dicingChar(series) { return series[~~(Math.random() * series.length)] } getPlate()