Skip to content

Commit 8f9c9d3

Browse files
committed
Completed 3-to-pounds.js exercise
1 parent 26947d3 commit 8f9c9d3

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

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+
// 3. Declares a variable with the value of "399" by truncating the character `p`
29+
// 8. Declares a variable with the value of "399" by prefixing with three `0`
30+
// but does not actually do that because the length of the string is 3 and prefixing three `0` exceeds the length
31+
// 9. Declares a variable by extracting the 3 pounds from the currency
32+
// by using the substring method starting from the beginning of the string and going up by 1 unit
33+
// 10. Declares a variable by extracting the pence from the currency
34+
// by using the substring method starting from the end of the string and then add 2 `0` but does not do that because it exceeds the length of the string
35+
// 18. Prints the currency by using the pounds variable prefixed with pound sign (£) and the pence variable which are separated with the . character

0 commit comments

Comments
 (0)