Skip to content

Commit ac59728

Browse files
committed
adjustments to the code in the 2-mandatory-debug folder and implementation of the 3-mandatory-implement folder
1 parent 6c6d86c commit ac59728

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,7 @@
1616

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

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,14 @@
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+
function toUpperSnakeCase(str) {
18+
// return the string in UPPER_SNAKE_CASE
19+
return str.toUpperCase().replace(/ /g, '_');
20+
}
21+
22+
// The function toUpperSnakeCase takes a string input and returns the string in UPPER_SNAKE_CASE. It first converts the string to uppercase using the toUpperCase() method, and then replaces all spaces with underscores using the replace() method with a regular expression.
23+
24+
// Now we can test the function with different inputs
25+
console.log(toUpperSnakeCase("hello there")); // Output: "HELLO_THERE"
26+
console.log(toUpperSnakeCase("lord of the rings")); // Output: "LORD_OF_THE_RINGS"
27+
console.log(toUpperSnakeCase("javascript is great")); // Output: "JAVASCRIPT_IS_GREAT"

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,10 @@
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+
function toPounds(kilograms) {
8+
return kilograms * 2.20462;
9+
}
10+
11+
console.log(toPounds(1)); // Output: 2.20462
12+
console.log(toPounds(10)); // Output: 22.0462
13+
console.log(toPounds(100)); // Output: 220.462

0 commit comments

Comments
 (0)