Skip to content

Commit ee0394d

Browse files
author
russom
committed
Explain how the program work
1 parent fbade85 commit ee0394d

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

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

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

2626
// To begin, we can start with
2727
// 1. const penceString = "399p": initialises a string variable with the value "399p"
28+
29+
// Answers
30+
31+
// 2. const penceStringWithoutTrailingP = penceString.substring(0, penceString.length - 1):
32+
// the substring() method returns the characters starting at index 0(3) up to and excluding the end(9) of penString variable.
33+
// This way only 399 is extracted of the string. Then the result is assigned to penceStringWithoutTrailingP variable.
34+
35+
// 3. const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"):
36+
// The method padStart(3, "0") adds the string 0 before penceStringWithoutTrailingP only

0 commit comments

Comments
 (0)