Skip to content

Commit b06d9e7

Browse files
committed
answered 3-mandatory 3-pounds.js
1 parent f35a334 commit b06d9e7

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,11 @@ 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+
// 2. const penceStringWithoutTrailingP = "399": returning with shorten less index to erase p
29+
// 3. const paddedPenceNumberString = "399"; It pads the string with the given length with specific string.
30+
// In this case, penceStringWithoutTrailingP (399) is already with 3 digis, so no change.
31+
// 4. const pounds = "3", getting part of the string by subString and target to get the string without last 2 digis.
32+
// 5. const pence = "99", subString indexStart counted by length of paddedPenceNumberString - 2 that is 1. So the result of
33+
//subString is 99. padEnd result the string with given length from the end of String. "99" length is 2 and already match
34+
//with the function. no change.
35+
//6. console.log = £3.99. The number refer to pounds and pence.

0 commit comments

Comments
 (0)