Skip to content

Commit 893336e

Browse files
committed
Add detailed explanation for paddedPenceNumberString processing in 3-to-pounds.js
1 parent ea7dbc1 commit 893336e

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎Sprint-2/3-mandatory-interpret/3-to-pounds.js‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,8 @@ console.log(`£${pounds}.${pence}`);
3030
// substring(0, length - 1): is a method that is invoked in the paragraph above to take every character in the string provided except the last one, leaving out the 'p'
3131
// That is -> '399p' becomes '399'
3232
// const penceStringWithoutTrailingP: used to store the value from 'penceString.substring(...)'
33-
33+
34+
// 3. const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0");
35+
// penceStringWithoutTrailingP is now '399'
36+
// padStart(3, "0") is a method which guarantees that the numeric string is at least 3 characters long, and if it is shorter add '0' to the front until it is 3 characters long.
37+
// padding to 3 ensures there is always at least one pounds digit and two pence digits.

0 commit comments

Comments
 (0)