Skip to content

Commit 3fcb050

Browse files
Merge branch 'main' into acoursework/sprint-2
2 parents 97abaaa + b31a586 commit 3fcb050

5 files changed

Lines changed: 19 additions & 10 deletions

File tree

Sprint-1/2-mandatory-errors/4.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
const 12HourClockTime = "20:53";
2-
const 24hourClockTime = "08:53";
1+
const 12HourClockTime = "8:53pm";
2+
const 24hourClockTime = "20:53";

Sprint-2/4-mandatory-interpret/time-format.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
function pad(num) {
2-
return num.toString().padStart(2, "0");
2+
let numString = num.toString();
3+
while (numString.length < 2) {
4+
numString = "0" + numString;
5+
}
6+
return numString;
37
}
48

59
function formatTimeDisplay(seconds) {
@@ -11,7 +15,7 @@ function formatTimeDisplay(seconds) {
1115
return `${pad(totalHours)}:${pad(remainingMinutes)}:${pad(remainingSeconds)}`;
1216
}
1317

14-
console.log(formatTimeDisplay(60))
18+
console.log(formatTimeDisplay(61))
1519
// You will need to play computer with this example - use the Python Visualiser https://pythontutor.com/visualize.html#mode=edit
1620
// to help you answer these questions
1721

@@ -26,13 +30,14 @@ console.log(formatTimeDisplay(60))
2630
// =============> the first time pad was called with the totalHours
2731

2832
// c) What is the return value of pad is called for the first time?
29-
// =============> "00"
33+
// =============> "0"
3034

3135

3236
// d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer
3337
// =============> "1"
3438
// the last time, pad() is called with the remaining seconds which is value "1"
3539

36-
// e) What is the return value assigned to num when pad is called for the last time in this program? Explain your answer
40+
// e) What is the return value of pad when it is called for the last time in this program? Explain your answer
3741
// =============> "01"
38-
// When it is called for the last time it adds 0 before 1 to make it 2 characters long
42+
43+

Sprint-3/1-implement-and-rewrite-tests/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ to choose test values that thoroughly test a function.
88
In the `implement` directory you've got a number of functions you'll need to implement.
99
For each function, you also have a number of different cases you'll need to check for your function.
1010

11-
Write your assertions and build up your program case by case. Don't rush to a solution. The point of these assignments is to learn how to write assertions and build up a program step by step.
11+
Write your implementation and your tests to cover the cases the function should fulfil.
1212

1313
Here is a recommended order:
1414

Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ try {
4646
getCardValue("invalid");
4747

4848
// This line will not be reached if an error is thrown as expected
49-
console.error("Error was not thrown for invalid card");
50-
} catch (e) {}
49+
console.error("Error was not thrown for invalid card 😢");
50+
} catch (e) {
51+
console.log("Error thrown for invalid card 🎉");
52+
}
5153

5254
// What other invalid card cases can you think of?

Sprint-3/2-practice-tdd/repeat-str.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
function repeatStr() {
2+
// Your implementation of this function must *not* call String.prototype.repeat (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat).
3+
// The goal is to re-implement that function, not to use it.
24
return "hellohellohello";
35
}
46

0 commit comments

Comments
 (0)