Skip to content

Commit 3bb0a7c

Browse files
reset file Sprint-2/2-mandatory-implement/3-to-pounds.js
1 parent 08290c6 commit 3bb0a7c

File tree

1 file changed

+0
-63
lines changed

1 file changed

+0
-63
lines changed

Sprint-2/3-mandatory-implement/3-to-pounds.js

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -4,66 +4,3 @@
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-
// const penceString = "9p"; //init variable
10-
11-
// const penceStringWithoutTrailingP = penceString.substring(
12-
// 0,
13-
// penceString.length - 1
14-
// ); //remove p character at the end of the variable
15-
// console.log(penceStringWithoutTrailingP);
16-
17-
// const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"); //
18-
// console.log(paddedPenceNumberString); //give format of 3 zeroes if the number is less than 3 digits.
19-
20-
// const pounds = paddedPenceNumberString.substring(
21-
// 0,
22-
// paddedPenceNumberString.length - 2
23-
// ); //get ponds value conversion changes for given pence
24-
25-
// console.log(pounds);
26-
27-
// const pence = paddedPenceNumberString
28-
// .substring(paddedPenceNumberString.length - 2)
29-
// .padEnd(2, "0"); //get the reminds after conversion to pounds
30-
31-
// console.log(`£${pounds}.${pence}`);
32-
33-
//------------------------------------------------------------------------------------------
34-
35-
function pensToPounds(penceString) {
36-
const penceStringWithoutTrailingP = penceString.substring(
37-
0,
38-
penceString.length - 1
39-
); //remove p character at the end of the variable
40-
//console.log(penceStringWithoutTrailingP);
41-
42-
const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"); //
43-
//console.log(paddedPenceNumberString); //give format of 3 zeroes if the number is less than 3 digits.
44-
45-
const pounds = paddedPenceNumberString.substring(
46-
0,
47-
paddedPenceNumberString.length - 2
48-
); //get ponds value conversion changes for given pence
49-
50-
//console.log(pounds);
51-
52-
const pence = paddedPenceNumberString
53-
.substring(paddedPenceNumberString.length - 2)
54-
.padEnd(2, "0"); //get the reminds after conversion to pounds
55-
56-
return ${pounds}.${pence}`;
57-
}
58-
59-
//test----1
60-
let moneyA = "90p";
61-
console.log(`${pensToPounds(moneyA)}`);
62-
63-
//test----2
64-
moneyA = "710p";
65-
console.log(`${pensToPounds(moneyA)}`);
66-
67-
//test----3
68-
moneyA = "1210p";
69-
console.log(`${pensToPounds(moneyA)}`);

0 commit comments

Comments
 (0)