Skip to content

Commit 442dbc8

Browse files
committed
test update
1 parent 5729ef6 commit 442dbc8

File tree

2 files changed

+26
-9
lines changed

2 files changed

+26
-9
lines changed

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
// Predict and explain first...
22

33
// =============> write your prediction here
4+
// The code will throw an error message because multiply only logged the result and didnt return it. So when we try to use the result of multiply(10, 32) in the template literal, it will be undefined, which will cause an error when trying to perform string interpolation with an undefined value.
45

5-
function multiply(a, b) {
6-
console.log(a * b);
7-
}
6+
// function multiply(a, b) {
7+
// console.log(a * b);
8+
//}
89

9-
console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);
10+
//console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);
1011

1112
// =============> write your explanation here
13+
// To fix this error, we need to change the multiply function to return the result of the multiplication instead of just logging it. This way, when we call multiply(10, 32) inside the template literal, it will return the correct value (320) that can be used in the string interpolation without causing an error.
1214

1315
// Finally, correct the code to fix the problem
1416
// =============> write your new code here
17+
18+
function multiply(a, b) {
19+
return a * b;
20+
}
21+
22+
console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); // output: The result of multiplying 10 and 32 is 320

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

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
// Predict and explain first...
22
// =============> write your prediction here
3+
// The code will throw an error message because the function "sum" has a return statement that is not returning any value.
34

4-
function sum(a, b) {
5-
return;
6-
a + b;
7-
}
5+
//function sum(a, b) {
6+
// return;
7+
// a + b;
8+
//}
89

9-
console.log(`The sum of 10 and 32 is ${sum(10, 32)}`);
10+
//console.log(`The sum of 10 and 32 is ${sum(10, 32)}`);
1011

1112
// =============> write your explanation here
13+
// The function "sum" is not returning any value.
14+
// To fix the error, we need to change the return statement to return the result of the addition of "a" and "b".
15+
1216
// Finally, correct the code to fix the problem
1317
// =============> write your new code here
18+
function sum(a, b) {
19+
return a + b;
20+
}
21+
22+
console.log(`The sum of 10 and 32 is ${sum(10, 32)}`);

0 commit comments

Comments
 (0)