Skip to content

Commit

Permalink
Use 3 digits to format their number
Browse files Browse the repository at this point in the history
  • Loading branch information
qsantos committed Oct 24, 2024
1 parent 4bfb213 commit a41c51c
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/contest.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ function randomCallSign() {
return prefix + numeral + suffix;
}

/**
* @param {number} number
* @return {string}
*/
function formatNumber(number) {
return String(number).padStart(3, '0');
}

/**
* @param {number} delay
*/
Expand Down Expand Up @@ -158,13 +166,13 @@ async function repeatCallSign() {
if (!await youSend(theirCallSign)) {
return;
}
await sleep(1000);
const paddedNumber = formatNumber(theirRealNumber);
if (theirCallSign === theirRealCallSign) {
await sleep(1000);
await theySend(`599 ${theirRealNumber}`);
await theySend(`599 ${paddedNumber}`);
document.getElementById("their-number").focus();
} else if (theirRealCallSign) {
await sleep(1000);
await theySend(`DE ${theirRealCallSign} 599 ${theirRealNumber}`);
await theySend(`DE ${theirRealCallSign} 599 ${paddedNumber}`);
}
}

Expand Down

0 comments on commit a41c51c

Please sign in to comment.