Skip to content

Commit 8a5ee4b

Browse files
committed
padStart, subString string.lenght Practice
1 parent 4d88962 commit 8a5ee4b

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Sprint-1/3-mandatory-interpret/3-to-pounds.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,18 @@ 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+
//lines 3 to 6= we asing a variable "penceStringWithoutTrailingP".
30+
//we use substring to start from index 0 and get the lenght 4 - 1 = 3
31+
// so sbtstring start form 0 and the length has 3 = 399
32+
33+
34+
// line 8. We declare variale "const paddedPenceNumberString" make sure the number number has least 3 digits
35+
36+
//line 9 to 12= use substring to extrac from start form index 0 and string lenght taking 2 digits = reusl 3
37+
38+
/// lines 14 to 16= const to the pence: the start indext for Substring will be 3-2= 1
39+
// substring with 1 argument wil start on the given indes and goes until the end = 99
40+
// padending (2, "0") will keep only 2 digits =99
41+
42+
// line 18 = template literal with the results £3.99

0 commit comments

Comments
 (0)