Skip to content

Commit 5d3ef36

Browse files
committed
interpret3 exercise complete
1 parent cae7b09 commit 5d3ef36

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,10 @@ 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+
//3. we are defining a new variable without the currency at the end that takes a sub string function from the penceString
29+
//4. the substring starts from index 0
30+
//5.until lenth of string -1 brfore last character
31+
//8. adds 0 char to the beginning of string until length is 3
32+
//9-11 Extracts a substring starting from the beginning of the string and stopping exactly 2 characters from the end
33+
//14-16 Extracts only the last two characters of the string. The .padEnd(2, "0") appends zeros to the right if the resulting string is somehow shorter than 2 characters
34+
//18 Uses a template literal to insert the pounds and pence variables into a new string, formatted with a pound symbol and a decimal point, and prints it to the console

0 commit comments

Comments
 (0)