Skip to content

Commit d3f986b

Browse files
Finished the last part of sprint 2 course work and ready for PR
1 parent 377fec1 commit d3f986b

File tree

4 files changed

+31
-2
lines changed

4 files changed

+31
-2
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+
return Number((weight / (height * height)).toFixed(1));
20+
}
21+
22+
console.log(calculateBMI(60,1.56));

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,8 @@
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 upperCaseSentence (word){
18+
return word.toUpperCase().replace(" ","_");
19+
};
20+
21+
console.log(upperCaseSentence("wake up"))

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+
8+
function toPounds (pence){
9+
let pound = pence * 0.01;
10+
return ${pound.toFixed(2)}`;
11+
};
12+
13+
console.log(toPounds("400"));

Sprint-2/4-mandatory-interpret/time-format.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,39 @@ function formatTimeDisplay(seconds) {
1010

1111
return `${pad(totalHours)}:${pad(remainingMinutes)}:${pad(remainingSeconds)}`;
1212
}
13-
13+
console.log(formatTimeDisplay(61));
1414
// You will need to play computer with this example - use the Python Visualiser https://pythontutor.com/visualize.html#mode=edit
1515
// to help you answer these questions
1616

1717
// Questions
1818

1919
// a) When formatTimeDisplay is called how many times will pad be called?
2020
// =============> write your answer here
21+
//when the function formatTimeDisplay when is called, the pad function will call 3 times.
2122

2223
// Call formatTimeDisplay with an input of 61, now answer the following:
2324

2425
// b) What is the value assigned to num when pad is called for the first time?
2526
// =============> write your answer here
27+
// The assign value to num when it first call is 0.
2628

2729
// c) What is the return value of pad is called for the first time?
2830
// =============> write your answer here
31+
// The return value of pad for the first time is 0.
2932

3033
// d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer
3134
// =============> write your answer here
3235

36+
/*The assign value to num when the function pad when it
37+
last called will be 1. Because when the pad function called for the third time, it will
38+
receive the value from the variable remainingSeconds(seconds % 60 = 1);
39+
*/
40+
3341
// e) What is the return value assigned to num when pad is called for the last time in this program? Explain your answer
3442
// =============> write your answer here
43+
/*
44+
the assign return value to num when the function pad when it last called will be 01,
45+
because the when the value remainingSeconds pass into the pad function. It will
46+
turn into string that will be add and combine "0" into the string "1" to the left because the padStart method check the total
47+
length of the string "1" and it is less then 2.
48+
*/

0 commit comments

Comments
 (0)