Skip to content

Commit 8cc0f09

Browse files
committed
mandatory implement part is done.
1 parent 494b2e5 commit 8cc0f09

File tree

3 files changed

+37
-2
lines changed

3 files changed

+37
-2
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
// Then when we call this function with the weight and height
1515
// It should return their Body Mass Index to 1 decimal place
1616

17+
const weight = 103;
18+
const height = 1.87;
19+
1720
function calculateBMI(weight, height) {
18-
// return the BMI of someone based off their weight and height
19-
}
21+
return calculatedBMI = (weight / (height * height)).toFixed(1);
22+
}
23+
24+
console.log(`the BMI of the person is ${calculateBMI(weight, height)}`);

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,11 @@
1414
// You will need to come up with an appropriate name for the function
1515
// Use the MDN string documentation to help you find a solution
1616
// This might help https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase
17+
18+
function magicToUpperCase(input)
19+
{
20+
return input.toUpperCase().replaceAll(" ", "_");
21+
22+
}
23+
24+
console.log(magicToUpperCase("lord of the rings"));

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,25 @@
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+
function toPounds(penceCount) {
10+
11+
const penceWithoutP = penceCount.substring(
12+
0,
13+
penceCount.length - 1
14+
);
15+
16+
const paddedPenceNumber = penceWithoutP.padStart(3, "0");
17+
const pounds = paddedPenceNumber.substring(
18+
0,
19+
paddedPenceNumber.length - 2
20+
);
21+
22+
const pence = paddedPenceNumber
23+
.substring(paddedPenceNumber.length - 2);
24+
25+
return `${pounds}.${pence}`;
26+
}
27+
28+
console.log(`The amount in pounds is ${toPounds("10000000")}`);

0 commit comments

Comments
 (0)