Skip to content

Commit 0142183

Browse files
author
AlanGit-debug2604
committed
3-to-pound.js : Refactor parameter name (wholePenceStringWithP) in toPound function for clarity; time-format.js updated comments with answers to questions
1 parent 9a86ff0 commit 0142183

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

‎Sprint-3/3-mandatory-implement/3-to-pounds.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// 3 paddedPenceNumberString ; assign and prescribe target length of pence in three characters length by .padStart()
1313
// 4 pounds ; assign pounds from first character of paddedPenceNumberString, cut the last two character by .substring
1414
// 5 pence ; assign pence starting from last two character of paddedPenceNumberString
15-
// Parameter to name penceStringWithP
15+
// Parameter to name wholePenceStringWithP
1616

1717
function toPound(wholePenceStringWithP) {
1818
const penceStringWithoutTrailingP = wholePenceStringWithP.substring(

‎Sprint-3/4-mandatory-interpret/time-format.js‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,25 @@ function formatTimeDisplay(seconds) {
1515
return `${pad(totalHours)}:${pad(remainingMinutes)}:${pad(remainingSeconds)}`;
1616
}
1717

18+
console.log(formatTimeDisplay(61));
19+
1820
// You will need to play computer with this example - use the Python Visualiser https://pythontutor.com/visualize.html#mode=edit
1921
// to help you answer these questions
2022

2123
// Questions
2224

2325
// a) When formatTimeDisplay is called how many times will pad be called?
24-
// =============> write your answer here
26+
// =============> Three times
2527

2628
// Call formatTimeDisplay with an input of 61, now answer the following:
2729

2830
// b) What is the value assigned to num when pad is called for the first time?
29-
// =============> write your answer here
31+
// =============> 0
3032

3133
// c) What is the return value of pad when it is called for the first time?
32-
// =============> write your answer here
34+
// =============> 00
3335

3436
// d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer
35-
// =============> write your answer here
36-
37+
// =============> 1. The last pad call takes `remainingSeconds` as its argument, and 61 % 60 =1 , so num is 1.
3738
// e) What is the return value of pad when it is called for the last time in this program? Explain your answer
38-
// =============> write your answer here
39+
// =============> 01. `numString` starts as "1", which has one character length. Since 1 < 1, the while lines run and pad "0", giving "01". Now this new `numString` has two characters length, so the while loop stops and returns "01".

0 commit comments

Comments
 (0)