Skip to content

Commit 78097f1

Browse files
authored
Enhance code readability with detailed comments
Added comments to explain the purpose of each line in the program.
1 parent ab458e3 commit 78097f1

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ console.log(`£${pounds}.${pence}`);
2222

2323
// You need to do a step-by-step breakdown of each line in this program
2424
// Try and describe the purpose / rationale behind each step
25+
//this function penceString.length-1 removes the last p from string so it values 3 because it contains 4 characters minues 1.
26+
//penceString.substring(0, 3) and it takes the characters from position 0 up to, but not including, position 3.
27+
//const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0");
28+
//const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0");This uses padStart() to make sure the string has at least 3 characters.
29+
//const pounds = paddedPenceNumberString.substring(0, paddedPenceNumberString.length - 2);
30+
//This line extracts the pounds part.
2531

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

0 commit comments

Comments
 (0)