Skip to content

Commit 8beb07d

Browse files
committed
Answering 3-to-pounds.js
1 parent 2478f22 commit 8beb07d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Sprint-1/3-mandatory-interpret/3-to-pounds.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,13 @@ 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+
// to begin we can start with
30+
//1- const penceSring= "399p": initialises a string variable with the value "399p"
31+
//2- const penceStringWithoutTrailingP= a string value "399" is reassigned to penceStringWithoutTrailingP by removing the last character "p" from penceString using the substring method
32+
//3- const paddedPenceNumberString= declared new variable, padStart ensure any argument passed is at least 3 characters long by adding leading zeros if necessary
33+
//4- line 9 a new variable pence is declared and its value comes from the padded string by removing the last two characters which represent the pence.
34+
//5- line 14 const pence= declared variable and the variable is the result after extracting the last two characters from paddedPenceNumberString using substring method and padEnd method is used to ensure that the pence value is always two digits long by adding trailing zeros if necessary
35+
// from the pence string and pads it to two characters to have two digits number.
36+
//6- line 18: console.log (`£${pounds}.${pence}`): returns money amount combing pounds and pence along with the £ symbol
37+
//eg. £3.99

0 commit comments

Comments
 (0)