Skip to content

Commit c9f3f14

Browse files
committed
removed an empty line
1 parent 5de407c commit c9f3f14

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

Sprint-2/implement/to-pounds.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,36 @@
44
// You will need to declare a function called toPounds with an appropriately named parameter.
55

66
// You should call this function a number of times to check it works for different inputs
7+
8+
9+
10+
11+
12+
const penceString = "399p";
13+
14+
const penceStringWithoutTrailingP = penceString.substring(
15+
0,
16+
penceString.length - 1
17+
);
18+
19+
const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0");
20+
const pounds = paddedPenceNumberString.substring(
21+
0,
22+
paddedPenceNumberString.length - 2
23+
);
24+
25+
const pence = paddedPenceNumberString
26+
.substring(paddedPenceNumberString.length - 2)
27+
.padEnd(2, "0");
28+
29+
console.log(${pounds}.${pence}`);
30+
31+
// This program takes a string representing a price in pence
32+
// The program then builds up a string representing the price in pounds
33+
34+
// You need to do a step-by-step breakdown of each line in this program
35+
// Try and describe the purpose / rationale behind each step
36+
37+
// To begin, we can start with
38+
// 1. const penceString = "399p": initialises a string variable with the value "399p"
39+

0 commit comments

Comments
 (0)