There was an error while loading. Please reload this page.
1 parent cec8b9b commit f86c338Copy full SHA for f86c338
1 file changed
Sprint-2/3-mandatory-interpret/3-to-pounds.js
@@ -25,3 +25,9 @@ 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
+// 2. const penceStringWithoutTrailingP = ...: removes the final "p" from "399p", leaving "399"
30
+// 3. padStart(3, "0"): makes sure the pence string has at least 3 characters by adding zeros to the beginning if needed.
31
+// 4. const pounds = ...: takes all the characters except the last two, giving the pounds part of the price.
32
+// 5. const pence = ...: takes the last two characters as the pence part and makes sure it has two characters.
33
+// 6. console.log(`£${pounds}.${pence}`): displays the final price in pounds and pence format.
0 commit comments