Skip to content

Commit b0b0990

Browse files
committed
The 3-to-pounds.js has been solved
1 parent 4dffed1 commit b0b0990

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: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,7 @@
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 BMI.toFixed(1);
20+
}
21+
console.log(calculateBMI(70,1.73));

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,22 @@
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 ConvertToUpperSnakeCase(s1)
19+
{
20+
let result = "";
21+
for(let i=0;i<s1.length;i++)
22+
{
23+
24+
if(s1[i]===" ")
25+
{
26+
result+=s1[i]="_";
27+
}
28+
else
29+
result+=s1[i];
30+
}
31+
let UPPER_SNAKE_CASE=result.toUpperCase();
32+
return UPPER_SNAKE_CASE;
33+
}
34+
console.log(ConvertToUpperSnakeCase("Ahmad Hmedan"));
35+

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,14 @@
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 toPound(penceString)
10+
{
11+
const penceWithoutP=penceString.substring(0,penceString.length-1);
12+
const paddedPence=penceWithoutP.padStart(3,"0");
13+
const pound=paddedPence.substring(0,paddedPence.length-2);
14+
const Pence=paddedPence.substring(paddedPence.length-2);
15+
return ${pound}.${Pence}`
16+
}
17+
console.log(toPound("100p"));

0 commit comments

Comments
 (0)