console.log('order_number', createOrderNumber(10)) function createOrderNumber(count){ var arr = ['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] let str = '' for(let i = 0; i < count; i++){ let numstr = arr[Math.floor(Math.random()*arr.length)] if(i == 0 && numstr == '0'){ console.log('numstr') return createOrderNumber(count) } str += numstr } return str.toUpperCase() }