File tree Expand file tree Collapse file tree
Sprint-2/3-mandatory-interpret Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -25,3 +25,11 @@ 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+ // 2. penceString.substring(0, penceString.length - 1): removes the final "p" character so only the digits remain
29+ // 3. padStart(3, "0"): ensures the value has at least 3 characters by adding leading zeros if needed
30+ // 4. pounds = the first part of the padded string, excluding the last two digits, so the whole pounds part is preserved
31+ // 5. pence = the final two digits, padded to 2 characters, to keep a valid pence value
32+ // 6. console.log(`£${pounds}.${pence}`): prints the formatted result as a pounds and pence string
33+
34+ // For "399p", the steps work like this:
35+ // "399p" -> "399" -> "399" -> pounds = "3" and pence = "99" -> output "£3.99"
You can’t perform that action at this time.
0 commit comments