-
-
Notifications
You must be signed in to change notification settings - Fork 119
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
WEST MIDLANDS-JAN-ITP|SEGUN FOLAYAN|STRCURING AND TESTING DATA|SPRINT2 #429
base: main
Are you sure you want to change the base?
Changes from 6 commits
8035635
94903a3
9295c66
ed867da
30bf077
168045e
1c5356a
13fc731
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,13 +1,19 @@ | ||
// Predict and explain first... | ||
// =============> write your prediction here | ||
// =============> write your prediction here: The code will not run because "let" should not be use in a function. | ||
|
||
// call the function capitalise with a string input | ||
// interpret the error message and figure out why an error is occurring | ||
// call the function capitalise with a string input: done | ||
// interpret the error message and figure out why an error is occurring: says string has already been declared. As said earlier "let" should be eliminated | ||
|
||
function capitalise(str) { | ||
let str = `${str[0].toUpperCase()}${str.slice(1)}`; | ||
return str; | ||
} | ||
|
||
// =============> write your explanation here | ||
|
||
// =============> write your explanation here: | ||
// Let is not needed to declare a variable inside a function. | ||
// =============> write your new code here | ||
function capitalise(str) { | ||
str = `${str[0].toUpperCase()}${str.slice(1)}`; | ||
return str; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,21 @@ | ||
// Predict and explain first... | ||
|
||
// =============> write your prediction here | ||
// =============> write your prediction here: the function has no return. Hence multiply ${multiply(10, 32)} will return undefined. | ||
|
||
function multiply(a, b) { | ||
console.log(a * b); | ||
} | ||
|
||
console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); | ||
console.log (`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); | ||
|
||
// =============> write your explanation here | ||
// =============> write your explanation here: | ||
// console.log(a*b) logs the result of the multiplication to the console but does not return any value. | ||
|
||
// 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,13 +1,20 @@ | ||
// Predict and explain first... | ||
// =============> write your prediction here | ||
// ${sum(10, 32)} will return undefined. | ||
|
||
function sum(a, b) { | ||
return; | ||
a + b; | ||
} | ||
|
||
console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); | ||
//console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); | ||
|
||
// =============> write your explanation here | ||
//Inside the function, return should not be followed by a semi-colon | ||
// Finally, correct the code to fix the problem | ||
// =============> write your new code here | ||
function sum(a, b) { | ||
return a + b; | ||
} | ||
|
||
console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,14 +10,15 @@ function formatTimeDisplay(seconds) { | |
|
||
return `${pad(totalHours)}:${pad(remainingMinutes)}:${pad(remainingSeconds)}`; | ||
} | ||
|
||
console.log(formatTimeDisplay(61)); | ||
// You will need to play computer with this example - use the Python Visualiser https://pythontutor.com/visualize.html#mode=edit | ||
// to help you answer these questions | ||
|
||
// Questions | ||
|
||
// a) When formatTimeDisplay is called how many times will pad be called? | ||
// =============> write your answer here | ||
//pad will be called three times | ||
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. You missed parts (b) to (e). 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. // a) When formatTimeDisplay is called how many times will pad be 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? // c) What is the return value of pad is called for the first time? // e) What is the return value assigned to num when pad is called for the last time in this program? Explain your answer |
||
|
||
// Call formatTimeDisplay with an input of 61, now answer the following: | ||
|
||
|
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.
How would you modify your code to achieve this?
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.
function calculateBMI(weight, height) {
}