File tree Expand file tree Collapse file tree
Sprint-2/2-mandatory-debug Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11// Predict and explain first...
22
33// =============> write your prediction here
4+ // 320
45
56function multiply ( a , b ) {
67 console . log ( a * b ) ;
@@ -10,5 +11,14 @@ console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);
1011
1112// =============> write your explanation here
1213
14+ / * E x p l a n a t i o n : T h e ` m u l t i p l y ` f u n c t i o n c a l c u l a t e s ` a * b ` a n d i m m e d i a t e l y p r i n t s i t t o
15+ the console , but it doesn 't use the `return` keyword to hand the value back.
16+
1317// Finally, correct the code to fix the problem
1418// =============> write your new code here
19+
20+ function multiply ( a , b ) {
21+ return a * b ;
22+ }
23+
24+ console . log ( `The result of multiplying 10 and 32 is ${ multiply ( 10 , 32 ) } ` ) ;
Original file line number Diff line number Diff line change 11// Predict and explain first...
22// =============> write your prediction here
33
4+ //The sum would return as undefined.
5+
46function sum ( a , b ) {
57 return ;
68 a + b ;
@@ -9,5 +11,15 @@ function sum(a, b) {
911console . log ( `The sum of 10 and 32 is ${ sum ( 10 , 32 ) } ` ) ;
1012
1113// =============> write your explanation here
14+
15+ // Explanation: The return keyword is used and the functions is not executed because the expression is on a different line
16+ which means the computer would not run the expression alongside the return keyword .
17+
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