Skip to content

Commit bb9e901

Browse files
committed
Address mentor feedback: clarify increment operation and explain padEnd is unnecessary
1 parent 82a4cf1 commit bb9e901

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed
Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1+
// This script shows how a counter changes step by step.
2+
13
let count = 0;
24

5+
// Line 3 increments the current value of count by 1.
6+
// It takes the current value of count (0), adds 1 to it,
7+
// and assigns the result (1) back to the count variable.
38
count = count + 1;
49

510
console.log(count);
6-
7-
// Line 1 is a variable declaration, creating the count variable with an initial value of 0
8-
// Describe what line 3 is doing, in particular focus on what = is doing
9-
10-
// Line 3 takes the current value of count (0), adds 1 to it,
11-
// and assigns the result (1) back to the count variable using =.

Sprint-1/3-mandatory-interpret/answers.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,11 @@ Also, minutes and seconds are not padded with leading zeros, so values like 2:3:
139139
- For `"399"`, length is 3, so substring(0, 1) → `"3"`.
140140

141141
5) `const pence = paddedPenceNumberString.substring(paddedPenceNumberString.length - 2).padEnd(2, "0");`
142-
- First, `substring(length - 2)` takes the last 2 digits.
143-
- Then `padEnd(2, "0")` ensures it’s at least 2 characters (adds zeros on the right if needed).
144-
- Purpose: get exactly two pence digits.
145-
- For `"399"`, last two digits are `"99"` → stays `"99"`.
142+
- First, `substring(paddedPenceNumberString.length - 2)` takes the last 2 characters.
143+
- Because `paddedPenceNumberString` has already been padded earlier with `padStart(3, "0")`, it will always be at least 3 characters long.
144+
- That means the substring operation already returns exactly 2 characters for any valid `penceString`.
145+
- So `.padEnd(2, "0")` is not actually needed in this script.
146+
- For `"399"`, the last two digits are `"99"`, so the result stays `"99"`.
146147

147148
6) `console.log(\`£${pounds}.${pence}\`);`
148149
- Uses a template literal to format the final currency string as pounds and pence.

0 commit comments

Comments
 (0)