Skip to content

Commit fbb60c9

Browse files
authored
Refine comments in 3-to-pounds.js
Updated comments for clarity and consistency.
1 parent 74dd263 commit fbb60c9

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,16 @@ console.log(`£${pounds}.${pence}`);
2525
//this function penceString.length-1 removes the last p from string so it values 3 because it contains 4 characters minues 1.
2626
//penceString.substring(0, 3) and it takes the characters from position 0 up to, but not including, position 3.
2727
//const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0");This uses padStart() to make sure the string has at least 3 characters.
28+
//padStart() adds characters to the begining of a string to make it 3 character long.
29+
2830
//const pounds = paddedPenceNumberString.substring(0, paddedPenceNumberString.length - 2);
31+
// we remove the last two characters and stores the remaining part of the string as pounds.
2932
//This line extracts the pounds part.
3033
//line14:penceString = "399p"
3134

3235
//paddedPenceNumberString is "399".
33-
//The substring() takes the last two characters, so:"399" → "99"
36+
//The substring() takes the last two characters as pence., so:"399" → "99"
3437
//Then .padEnd(2, "0") checks the string is at least 2 characters long. If it already has 2 characters, like "99", without changing the rest.
35-
//padEnd(2, "0") adds "0" to the end of the string until it reaches a length of 2 and finally line 18 prints the result which is £3.99
38+
//padEnd(2, "0") adds "0" to the end of the string until it reaches a length of 2.
39+
//finally line 18 combines pound and pence which is £3.99
3640

0 commit comments

Comments
 (0)