Skip to content

Commit f35bfdc

Browse files
authored
Improve comments for pence to pounds conversion
Updated comments to clarify the conversion process from pence to pounds.
1 parent b48ce39 commit f35bfdc

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
@@ -28,6 +28,10 @@ console.log(`£${pounds}.${pence}`);
2828
//const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0");This uses padStart() to make sure the string has at least 3 characters.
2929
//const pounds = paddedPenceNumberString.substring(0, paddedPenceNumberString.length - 2);
3030
//This line extracts the pounds part.
31+
//line14:penceString = "399p"
32+
33+
//paddedPenceNumberString is "399".
34+
//The substring() takes the last two characters, so:"399" → "99"
35+
//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.
36+
//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
3137

32-
// To begin, we can start with
33-
// 1. const penceString = "399p": initialises a string variable with the value "399p"

0 commit comments

Comments
 (0)