Skip to content

Commit ca85fbb

Browse files
explained code execution
1 parent e9597fb commit ca85fbb

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,10 @@ 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+
// line 1 creating a string containing price in pence and this is starting value that programme will convert into pound.
30+
// line 3 removing p from the end of 399p because p is not needed when converting into pound or pence.
31+
// line 8 making sure string has at least 3 digit by adding zero if needed and this makes easier to separate pound and pence consistently.
32+
// line 9 extract everything except last two digit .
33+
// line 14 extract last two digit and padEnd() ensures the pence part always has 2 digits.
34+
// line 18 to print value for checking .

0 commit comments

Comments
 (0)