Skip to content

Commit 3629cf5

Browse files
authored
Enhance comments for clarity in 3-to-pounds.js
Added comments explaining the purpose of each step in the code.
1 parent 3bb4629 commit 3629cf5

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
/*
29+
3-6. It is taking the vaule from pencestring and using substring to return part of the string, by -1 so from the end resualting in "399"
30+
8. It is now adding "0" infront of vaule if the vaule is under 3 characters in size.
31+
9-12. Using the substring function to reduce the size of the vaule to just 2 characters.
32+
14-16. Taking the value from paddedPenceNumberString and this time with substring, only showing the last 2 characters in teh value.
33+
Then with using .padEnd it ensures that 2 characters are shown with 0 being there is nothing is there.
34+
18. howing the resualt of the code starting with a "£" then the value of "pounds" then a "." and lastly value of "pence"
35+
*/

0 commit comments

Comments
 (0)