File tree Expand file tree Collapse file tree 3 files changed +32
-0
lines changed
Sprint-2/2-mandatory-debug Expand file tree Collapse file tree 3 files changed +32
-0
lines changed Original file line number Diff line number Diff line change 11// Predict and explain first...
22
33// =============> write your prediction here
4+ // multiply function is to return the product of a and b
45
56function multiply ( a , b ) {
67 console . log ( a * b ) ;
@@ -9,6 +10,14 @@ function multiply(a, b) {
910console . log ( `The result of multiplying 10 and 32 is ${ multiply ( 10 , 32 ) } ` ) ;
1011
1112// =============> write your explanation here
13+ //The logic for multiplication is in the console.log() function which main purpose is to log it to the console.
1214
1315// Finally, correct the code to fix the problem
16+
1417// =============> write your new code here
18+
19+ //function multiply(a, b) {
20+ // return (a * b);
21+ //}
22+
23+ //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
3+ // This function is to return the sum of a and b
34
45function sum ( a , b ) {
56 return ;
@@ -9,5 +10,13 @@ function sum(a, b) {
910console . log ( `The sum of 10 and 32 is ${ sum ( 10 , 32 ) } ` ) ;
1011
1112// =============> write your explanation here
13+ // the function above throw error because it is terminated by the return statement even before it gets to the operation
1214// Finally, correct the code to fix the problem
15+
1316// =============> write your new code here
17+
18+ //function sum(a, b) {
19+ // return a + b;
20+ //}
21+
22+ //console.log(`The sum of 10 and 32 is ${sum(10, 32)}`);
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+ //This code convert number to string and make a copy of the last character using the reverse indexing
56
67const num = 103 ;
78
@@ -15,10 +16,23 @@ console.log(`The last digit of 806 is ${getLastDigit(806)}`);
1516
1617// Now run the code and compare the output to your prediction
1718// =============> write the output here
19+ //The last digit of 42 is 3
20+ //The last digit of 105 is 3
21+ //The last digit of 806 is 3
22+
1823// Explain why the output is the way it is
1924// =============> write your explanation here
25+ //The output is the way it is because the variable was declared as a fixed global variable and not as a function parameter
2026// Finally, correct the code to fix the problem
2127// =============> write your new code here
2228
29+ //function getLastDigit(num) {
30+ //return num.toString().slice(-1);
31+ //}
32+
33+ //console.log(`The last digit of 42 is ${getLastDigit(42)}`);
34+ //console.log(`The last digit of 105 is ${getLastDigit(105)}`);
35+ //console.log(`The last digit of 806 is ${getLastDigit(806)}`);
36+
2337// This program should tell the user the last digit of each number.
2438// Explain why getLastDigit is not working properly - correct the problem
You can’t perform that action at this time.
0 commit comments