There was an error while loading. Please reload this page.
1 parent fbade85 commit ee0394dCopy full SHA for ee0394d
1 file changed
Sprint-2/3-mandatory-interpret/3-to-pounds.js
@@ -25,3 +25,12 @@ 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
+// Answers
30
31
+// 2. const penceStringWithoutTrailingP = penceString.substring(0, penceString.length - 1):
32
+// the substring() method returns the characters starting at index 0(3) up to and excluding the end(9) of penString variable.
33
+// This way only 399 is extracted of the string. Then the result is assigned to penceStringWithoutTrailingP variable.
34
35
+// 3. const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"):
36
+// The method padStart(3, "0") adds the string 0 before penceStringWithoutTrailingP only
0 commit comments