Skip to content

Commit 87fc640

Browse files
committed
Fixed First PR Review
1 parent 65c1eac commit 87fc640

File tree

3 files changed

+24
-9
lines changed

3 files changed

+24
-9
lines changed

Sprint-2/2-mandatory-debug/1.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ function sum(a, b) {
1010
console.log(`The sum of 10 and 32 is ${sum(10, 32)}`);
1111

1212
// =============> write your explanation here
13-
// the function above throw error because it is terminated by the return statement even before it gets to the operation
13+
// the function above returns undefined because the return statement terminates
14+
// the code before it gets to the operation (a+b)
1415
// Finally, correct the code to fix the problem
1516

1617
// =============> write your new code here

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,9 @@ function snakeCasing(str) {
2222
}
2323

2424
console.log(snakeCasing("ofonime edak"));
25+
26+
function snakeCasingAlt(str) {
27+
return str.toUpperCase().replaceAll(" ", "_");
28+
}
29+
30+
console.log(snakeCasingAlt("ofonime edak Sunday"));
Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
function pad(num) {
2-
return num.toString().padStart(2, "0");
2+
console.log(num);
3+
const result = num.toString().padStart(2, "0");
4+
console.log(result);
5+
return result;
36
}
47

58
function formatTimeDisplay(seconds) {
@@ -8,30 +11,35 @@ function formatTimeDisplay(seconds) {
811
const remainingMinutes = totalMinutes % 60;
912
const totalHours = (totalMinutes - remainingMinutes) / 60;
1013

11-
return `${pad(totalHours)}:${pad(remainingMinutes)}:${pad(remainingSeconds)}`;
14+
const time = `${pad(totalHours)}:${pad(remainingMinutes)}:${pad(remainingSeconds)}`;
15+
console.log(time);
16+
return time;
1217
}
1318

19+
formatTimeDisplay(61);
20+
1421
// You will need to play computer with this example - use the Python Visualiser https://pythontutor.com/visualize.html#mode=edit
1522
// to help you answer these questions
1623

1724
// Questions
1825

1926
// a) When formatTimeDisplay is called how many times will pad be called?
2027
// =============> write your answer here
21-
// Pad is called once.
28+
// Pad is called three times in line 11 of the formatTimeDisplay().
2229
// Call formatTimeDisplay with an input of 61, now answer the following:
2330

2431
// b) What is the value assigned to num when pad is called for the first time?
2532
// =============> write your answer here
26-
// value of num=undefined
33+
// value of num=0
2734
// c) What is the return value of pad is called for the first time?
2835
// =============> write your answer here
29-
// it returns a function object
36+
// it returns 00
3037

3138
// d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer
3239
// =============> write your answer here
33-
//value is 0
34-
//the frame side when pad is called the last time num is assigned a value of 0
40+
//value is 1
41+
//the frame side when pad is called the last time num is assigned a value of 01
3542

3643
// e) What is the return value assigned to num when pad is called for the last time in this program? Explain your answer
37-
// =============> write your answer here
44+
// =============> write your answer here num is assigned a value of one when pad is called for the
45+
// last time by the formatTimeDisplay function this value is used to evaluate the remaining seconds.

0 commit comments

Comments
 (0)