Skip to content

Commit a6c691a

Browse files
committed
3-mandatory-implement Done
1 parent 4ccd588 commit a6c691a

File tree

4 files changed

+51
-2
lines changed

4 files changed

+51
-2
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@ node_modules
22
.DS_Store
33
.vscode
44
testing.js --- IGNORE ---
5-
testing.js
65
**/.DS_Store

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

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

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

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,20 @@
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 toUpperSnakeCase(string)
19+
{
20+
let output = '';
21+
for(let i = 0; i < string.length; i++)
22+
{
23+
let char = string[i];
24+
if(char === " ")
25+
{
26+
char = "_";
27+
}
28+
output += char;
29+
}
30+
return output.toUpperCase();
31+
}
32+
33+
console.log(toUpperSnakeCase("Hello there, How are you doing guys?"));

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,29 @@
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+
function toPounds(penceString)
9+
{
10+
const penceStringWithoutTrailingP = penceString.substring(
11+
0,
12+
penceString.length - 1
13+
);
14+
15+
const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0");
16+
const pounds = paddedPenceNumberString.substring(
17+
0,
18+
paddedPenceNumberString.length - 2
19+
);
20+
21+
const pence = paddedPenceNumberString
22+
.substring(paddedPenceNumberString.length - 2)
23+
.padEnd(2, "0");
24+
25+
return (${pounds}.${pence}`);
26+
}
27+
28+
console.log(toPounds("5764p"));
29+
console.log(toPounds("813p"));
30+
console.log(toPounds("90897867564p"));
31+
console.log(toPounds("71p"));
32+
console.log(toPounds("312987p"));

0 commit comments

Comments
 (0)