There was an error while loading. Please reload this page.
1 parent 60c1518 commit 8ee83a9Copy full SHA for 8ee83a9
1 file changed
Sprint-3/3-mandatory-implement/3-to-pounds.js
@@ -5,12 +5,9 @@
5
6
// You should call this function a number of times to check it works for different inputs
7
function toPounds(penceString) {
8
- const penceStringWithoutTrailingP = penceString.substring(
9
- 0,
10
- penceString.length - 1,
11
- );
+ const penceNumberString = String(penceString).replace(/p$/i, "");
+ const paddedPenceNumberString = penceNumberString.padStart(3, "0");
12
13
- const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0");
14
const pounds = paddedPenceNumberString.substring(
15
0,
16
paddedPenceNumberString.length - 2,
0 commit comments