Skip to content

Commit 9f6a5e5

Browse files
committed
Defined the return function of sum to a + b.
1 parent ea78769 commit 9f6a5e5

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function multiply(a, b) {
1111
console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);
1212

1313
// =============> write your explanation here
14-
// console.log is use to print the instead of return such that the return value can be called at the end.
14+
// console.log is use to print the instead osf return such that the return value can be called at the end.
1515
// Finally, correct the code to fix the problem
1616
// =============> write your new code here
1717
function multiply(a, b) {

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Predict and explain first...
22
// =============> write your prediction here
3-
3+
// The return and a + b are on 2 different lines leading to a syntax error. The sum fuctions does not work like this.
44
function sum(a, b) {
55
return;
66
a + b;
@@ -9,5 +9,12 @@ function sum(a, b) {
99
console.log(`The sum of 10 and 32 is ${sum(10, 32)}`);
1010

1111
// =============> write your explanation here
12+
13+
//The code runs but gives undefined in the console when we call the sum(10, 32). The return function is not defined. We must define it a + b so that when we call it, it give the sum of the 2 values
1214
// Finally, correct the code to fix the problem
1315
// =============> write your new code here
16+
function sum(a, b) {
17+
return a + b;
18+
}
19+
20+
console.log(`The sum of 10 and 32 is ${sum(10, 32)}`);

0 commit comments

Comments
 (0)