-
-
Notifications
You must be signed in to change notification settings - Fork 221
West Midlands | ITP-Sep-2025 | Ahmad Ehsas | Sprint 2 | Structuring and Testing Data #734
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 10 commits
65fe894
c2e158f
5e632d2
4cdfdd4
eb5e0dc
a696e17
84ed53e
7a09127
f813ae6
6e2a97e
6d07e0b
eaad7ed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,18 @@ | ||
// Predict and explain first... | ||
|
||
// =============> write your prediction here | ||
// =============> write your prediction here: the value of a and b is not defined in the function and the return statement is missing.// | ||
|
||
function multiply(a, b) { | ||
console.log(a * b); | ||
} | ||
|
||
console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); | ||
|
||
// =============> write your explanation here | ||
// =============> write your explanation here: The code is running but it has technical issue. the multiply function logs the result but does not return it.We need to use return function to use the result inside the string.// | ||
|
||
// Finally, correct the code to fix the problem | ||
// =============> write your new code here | ||
//function multiply(a, b) { | ||
// return a * b; | ||
//} | ||
// console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
// Predict and explain first... | ||
// =============> write your prediction here | ||
// =============> write your prediction here: The return function is not defined, so the function will not return the sum of a and b. | ||
|
||
function sum(a, b) { | ||
return; | ||
|
@@ -8,6 +8,9 @@ function sum(a, b) { | |
|
||
console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); | ||
|
||
// =============> write your explanation here | ||
// =============> write your explanation here: in the code above, the function Sum is not returning because the return function is not defined and it is written incorrectly. The return function should be written before the a + b values.// | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could say the statement |
||
// Finally, correct the code to fix the problem | ||
// =============> write your new code here | ||
// function sum(a, b) { | ||
// return a + b; | ||
// } |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,18 +17,18 @@ function formatTimeDisplay(seconds) { | |
// Questions | ||
|
||
// a) When formatTimeDisplay is called how many times will pad be called? | ||
// =============> write your answer here | ||
// =============> write your answer here: When formatTimeDisplay is called four times pad will be called, one for remainingSeconds, one for remainingMinutes, one for totalMinutes and one for totalHours. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The function There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you want to update the answer on line 20? We only see 3 times the pad is called? |
||
|
||
// Call formatTimeDisplay with an input of 61, now answer the following: | ||
|
||
// b) What is the value assigned to num when pad is called for the first time? | ||
// =============> write your answer here | ||
// =============> write your answer here: When pad is called for thee first time, num will be assigned the value of 1, which is the value of remainingSeconds. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you spot where the function There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The function pad first called is: |
||
|
||
// c) What is the return value of pad is called for the first time? | ||
// =============> write your answer here | ||
// =============> write your answer here: The return value of pad when called for the first time will be `01` because it pads the number 1 with a leading zero to make it two digits. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. when you find out when the function |
||
|
||
// d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer | ||
// =============> write your answer here | ||
// =============> write your answer here: When pad is called for the last time, num will be assigned the value of 0, which is the value of totalHours. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Like above, we can find out when a function is called first based on the order in which it is called in the series. In other words, which appears first in the series. |
||
|
||
// e) What is the return value assigned to num when pad is called for the last time in this program? Explain your answer | ||
// =============> write your answer here | ||
// =============> write your answer here: when pad is called for the last time, the return value will be `0` because it pads the number 0 with a leading zero to make it two digits. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will also change when we know the above. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think console.log() is calling an undeclared variable
decimalNumber
instead of the functionconvertToPercentage(0.5)
? You have corrected the function on line 25.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed the issue, and as a comment, the code is now fixed.