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+ // I think the function will not work because nothing is returned
45
56function multiply ( a , b ) {
6- console . log ( a * b ) ;
7+ return a * b ;
78}
89
910console . log ( `The result of multiplying 10 and 32 is ${ multiply ( 10 , 32 ) } ` ) ;
1011
1112// =============> write your explanation here
13+ // I was almost correct but I had to also remove the console.log()
1214
1315// Finally, correct the code to fix the problem
1416// =============> write your new code here
17+ // 10: return a * b;
Original file line number Diff line number Diff line change 11// Predict and explain first...
22// =============> write your prediction here
3+ // It won't run because there's a semicolon straight after return
34
45function sum ( a , b ) {
5- return ;
6- a + b ;
6+ return a + b ;
77}
88
99console . log ( `The sum of 10 and 32 is ${ sum ( 10 , 32 ) } ` ) ;
1010
1111// =============> write your explanation here
1212// Finally, correct the code to fix the problem
1313// =============> write your new code here
14+ // remove the semicolon
Original file line number Diff line number Diff line change 22
33// Predict the output of the following code:
44// =============> Write your prediction here
5+ // I think it wont run because there's nothing passed into the function
6+ // also it is using the value of num outside of the function wich isn't correct
57
6- const num = 103 ;
7-
8- function getLastDigit ( ) {
8+ function getLastDigit ( num ) {
99 return num . toString ( ) . slice ( - 1 ) ;
1010}
1111
@@ -14,11 +14,13 @@ console.log(`The last digit of 105 is ${getLastDigit(105)}`);
1414console . log ( `The last digit of 806 is ${ getLastDigit ( 806 ) } ` ) ;
1515
1616// Now run the code and compare the output to your prediction
17- // =============> write the output here
17+ // =============> it just returned 3
18+
1819// Explain why the output is the way it is
19- // =============> write your explanation here
20+ // =============> Because value is mistakenly defined outside of the function
21+
2022// Finally, correct the code to fix the problem
21- // =============> write your new code here
23+ // =============> pass num into the function and remove the constant 103 outside
2224
2325// This program should tell the user the last digit of each number.
2426// Explain why getLastDigit is not working properly - correct the problem
You can’t perform that action at this time.
0 commit comments