Skip to content

Commit fc46f16

Browse files
committed
fixed 3-mandatory-implements
1 parent a858eb9 commit fc46f16

File tree

3 files changed

+29
-23
lines changed

3 files changed

+29
-23
lines changed

Sprint-2/3-mandatory-implement/1-bmi.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,8 @@
1616

1717
function calculateBMI(weight, height) {
1818
// return the BMI of someone based off their weight and height
19-
console.log("weight", weight);
20-
console.log("height",height);
21-
22-
const heightSquared = (height * height).toFixed(2);
23-
console.log("heightSquared",heightSquared);
24-
const BMI = (weight / heightSquared).toFixed(2);
25-
console.log("BMI",BMI)
26-
return BMI;
19+
20+
const heightSquared = (height * height);
21+
const BMI = (weight / heightSquared).toFixed(1);
22+
return Number(BMI);
2723
}
28-
console.log("calculateBMI",calculateBMI(70, 1.73))

Sprint-2/3-mandatory-implement/2-cases.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
// This might help https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase
1717

1818
function makeUpperCaseSnakeCase(str){
19-
const result = str.split(" ").join("_").toUpperCase(); //take str, and turn it into an array and then turn it back into a string with underscores then upper case it.
20-
console.log("result",result);
19+
// .replaceAll takes the empty space and replaces it with underscore and .toUpperCase makes all the letters capitals.
20+
const result = str.replaceAll(" ", "_").toUpperCase();
21+
return result;
2122
}
22-
23-
console.log(makeUpperCaseSnakeCase("hello there"));

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

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,29 @@
55

66
// You should call this function a number of times to check it works for different inputs
77

8-
let count = 0;
98

10-
count = count + 1;
9+
function toPounds(penceString) {
10+
11+
const penceStringWithoutTrailingP = penceString.substring(
12+
0,
13+
penceString.length - 1
14+
);
1115

12-
function toPounds(pennies) {
13-
let pounds = pennies / 100;
14-
return pounds;
16+
const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0");
17+
const pounds = paddedPenceNumberString.substring(
18+
0,
19+
paddedPenceNumberString.length - 2
20+
);
21+
22+
const pence = paddedPenceNumberString
23+
.substring(paddedPenceNumberString.length - 2)
24+
.padEnd(2, "0");
25+
26+
return ${pounds}.${pence}`
1527
}
1628

17-
console.log(toPounds(50));
18-
console.log(toPounds(100));
19-
console.log(toPounds(150));
20-
console.log(toPounds(250));
21-
console.log(toPounds(350));
29+
console.log(toPounds("50p"));
30+
console.log(toPounds("103p"));
31+
console.log(toPounds("155p"));
32+
console.log(toPounds("5043p"));
33+
console.log(toPounds("689732p"));

0 commit comments

Comments
 (0)