File tree Expand file tree Collapse file tree 2 files changed +12
-8
lines changed
Sprint-2/2-mandatory-debug Expand file tree Collapse file tree 2 files changed +12
-8
lines changed Original file line number Diff line number Diff line change 11// Predict and explain first...
22
33// =============> write your prediction here
4- // the function will not return anything.
4+
5+ // the function will not return anything, as there is no return.
6+
57function multiply ( a , b ) {
68 console . log ( a * b ) ;
79}
@@ -10,7 +12,7 @@ console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);
1012
1113// =============> write your explanation here
1214
13- // declared a variable called result and stored a*b.
15+ // declared a variable called result and stored a*b, then return result in the function .
1416
1517// Finally, correct the code to fix the problem
1618// =============> write your new code here
Original file line number Diff line number Diff line change 22// =============> write your prediction here
33// This appears correct. The function has been defined and called sum, a is 10 and b is 32 so we should get 42.
44function sum ( a , b ) {
5- return ;
6- a + b ;
5+ return ;
6+ a + b
77}
88
99console . log ( `The sum of 10 and 32 is ${ sum ( 10 , 32 ) } ` ) ;
1010
1111// =============> write your explanation here
12- // The sum of 10 and 32 is undefined. On line five the function has been exited because of the ; this because the function doesn't return anything.
12+
13+ // The sum of 10 and 32 is undefined. On line five the function has been exited early because of the return;
14+ // a + b need to be on the same line as the return otherwise you'd get "unreachable code detected" error.
15+
1316// Finally, correct the code to fix the problem
17+
1418// =============> write your new code here
1519
1620 function sum ( a , b ) {
1721 return a + b ;
18- }
19-
20- console . log ( `The sum of 10 and 32 is ${ sum ( 10 , 32 ) } ` ) ;
22+ }
You can’t perform that action at this time.
0 commit comments