We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c958014 commit 7ab586cCopy full SHA for 7ab586c
1 file changed
Sprint-2/3-mandatory-implement/3-to-pounds.js
@@ -4,3 +4,23 @@
4
// You will need to declare a function called toPounds with an appropriately named parameter.
5
6
// You should call this function a number of times to check it works for different inputs
7
+function toPounds(penceString)
8
+{
9
+ const penceStringWithoutTrailingP = penceString.substring(
10
+ 0,
11
+ penceString.length - 1
12
+ );
13
+
14
+ const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0");
15
+ const pounds = paddedPenceNumberString.substring(
16
17
+ paddedPenceNumberString.length - 2
18
19
20
+ const pence = paddedPenceNumberString
21
+ .substring(paddedPenceNumberString.length - 2)
22
+ .padEnd(2, "0");
23
24
+ return(`£${pounds}.${pence}`);
25
26
+}
0 commit comments