彩券生產器


Posted by mijouhsieh on 2022-03-30

彩券規格:

  • 分別獨立產生6個字符
  • 前2格字符為大寫英文字母
  • 後4個字符為數字
    再次複習 replit

思考流程圖

flowchart

程式碼

常錯的地方
出錯的地方:沒有分別獨立產生6個字符
亂數應在每次for loop產生一個字符,所以要寫在for loop內,而不是統一寫在for loop上方。


修正
其實可以不用 numbers陣列,當ticketNumber = Math.floor(Math.random()*10) 就可以隨機產生0 ~ 9的數字了


不用 numbers陣列


#ticket-generator #隨機號碼







Related Posts

DAY41:Equal Sides Of An Array

DAY41:Equal Sides Of An Array

[Day04] Currying, Pointfree, Higher Order Function

[Day04] Currying, Pointfree, Higher Order Function

[Release Notes] 20210317_v1 - Support Insert img path and save button in post editor

[Release Notes] 20210317_v1 - Support Insert img path and save button in post editor


Comments