File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
Sprint-2/2-mandatory-debug Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change 11// Predict and explain first...
22// =============> write your prediction here
3-
3+ // The function returns nothing because the return statement has no value.
4+ // Once JavaScript reaches return, the function stops executing.
5+ // Therefore, the line after it is dead code and never runs.
6+ // Since the function does not return a value, it returns undefined, which is why the template string displays undefined.
47function sum ( a , b ) {
58 return ;
69 a + b ;
@@ -9,5 +12,14 @@ function sum(a, b) {
912console . log ( `The sum of 10 and 32 is ${ sum ( 10 , 32 ) } ` ) ;
1013
1114// =============> write your explanation here
15+ // The function now correctly returns the result of a + b.
16+ // Since the addition is included in the return statement, the function sends back the calculated value.
17+ // Therefore, when the function is called inside the template string, it displays the correct result, 42.
1218// Finally, correct the code to fix the problem
1319// =============> write your new code here
20+
21+ function sum ( a , b ) {
22+ return a + b ;
23+ }
24+
25+ console . log ( `The sum of 10 and 32 is ${ sum ( 10 , 32 ) } ` ) ;
You can’t perform that action at this time.
0 commit comments