There was an error while loading. Please reload this page.
1 parent e9cb419 commit 6b08bbcCopy full SHA for 6b08bbc
1 file changed
Sprint-2/3-mandatory-interpret/3-to-pounds.js
@@ -25,3 +25,17 @@ console.log(`£${pounds}.${pence}`);
25
26
// To begin, we can start with
27
// 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