Skip to content

Commit 6549aaa

Browse files
committed
Implement completed
1 parent 1a63f23 commit 6549aaa

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,8 @@
1515
// It should return their Body Mass Index to 1 decimal place
1616

1717
function calculateBMI(weight, height) {
18-
// return the BMI of someone based off their weight and height
19-
}
18+
let bmi = weight / (height * height);
19+
return Math.round(bmi * 10) / 10
20+
}
21+
22+
// console.log(calculateBMI(68, 1.7));

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,10 @@
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 toUpperSnake(str) {
19+
return str.split(" ").map(item => item.toUpperCase()).join("_");
20+
}
21+
22+
console.log(toUpperSnake("lord of the rings"));
23+
// returns 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+
// Method 1
9+
function toPounds(penceString) {
10+
let penceStringWithoutP = penceString.substring(0, penceString.length - 1);
11+
let paddedPenceNumberString = penceStringWithoutP.padStart(3, "0");
12+
let pound = paddedPenceNumberString.substring(0, paddedPenceNumberString.length - 2);
13+
let pence = paddedPenceNumberString.substring(paddedPenceNumberString.length - 2);
14+
15+
return ${pound}.${pence}`;
16+
17+
}
18+
console.log(toPounds("447p")); // £4.47
19+
20+
21+
22+
// Method 2
23+
function toPounds(penceString) {
24+
let value = Number(penceString.slice(0, -1)) / 100;
25+
return ${value.toFixed(2)}`
26+
}
27+
28+
console.log(toPounds("447p")); // £4.47

0 commit comments

Comments
 (0)