Code screenshot

Javascript 入門:Continue statement

let termOfOffice = 5; // 5年任期 let numOfYear = 0; let president; while (true) { if (numOfYear % termOfOffice !== 0) { continue; // 未夠期換屆 } else { president = getNextPresident(); // 換屆 } if (president === '習近平') { termOfOffice = Infinity; } numOfYear++; }

July 3, 2022 Â· 1 min Â· 45 words Â· Me
Code screenshot

唔怕比小朋友撞倒?

July 2, 2022 Â· 0 min Â· 0 words Â· Me
Code screenshot

香港回歸廿五年有冇變?

import HongKong from 'asia/HongKong'; // constants 用全大階同 underscores const DATE_OF_HANDOVER = new Date(1997, 6, 1); // 1997-07-01T00:00:00.000Z const YEARS_NO_CHANGE = 50; // 說好的50年 const now = new Date(); // 2022-07-01T00:00:00.000Z // return boolean 可以用 prefix function isHongKongNoChange(date: Date): Boolean { const diffInYear = now.getFullYear() - DATE_OF_HANDOVER.getFullYear(); const withInNoChangePeriod = diffInYear < YEARS_NO_CHANGE; // HongKong class 有 static method 類似 Date 可以 instantize 喺指定時間 const oldHongKong = HongKong.from(DATE_OF_HANDOVER); const nowHongKong = HongKong....

July 1, 2022 Â· 1 min Â· 98 words Â· Me