Skip to content

Commit 6b08bbc

Browse files
answer 3.3
1 parent e9cb419 commit 6b08bbc

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,17 @@ 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+
// Answer
30+
31+
// penceString = "399p" — stores the price as a string
32+
33+
// penceStringWithoutTrailingP — removes the final "p", giving "399"
34+
35+
// paddedPenceNumberString — adds leading zeros if necessary so the string has at least 3 digits.
36+
37+
// pounds — takes all the characters except the last two, giving "3"
38+
39+
// pence — takes the last two characters, giving "99", and ensures there are two digits
40+
41+
// console.log — combines the pounds and pence and displays £3.99

0 commit comments

Comments
 (0)