Skip to content

Commit 7b87fbc

Browse files
authored
Update 2.js
1 parent 7d09f40 commit 7b87fbc

File tree

1 file changed

+3
-15
lines changed
  • Sprint-2/2-mandatory-debug

1 file changed

+3
-15
lines changed

Sprint-2/2-mandatory-debug/2.js

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
// Predict and explain first...
22

33
// Predict the output of the following code:
4-
// =============>
5-
// The last digit of 42 is 3
6-
// The last digit of 105 is 3
7-
// The last digit of 806 is 3
4+
// =============> Write your prediction here
85

96
const num = 103;
107

@@ -17,20 +14,11 @@ console.log(`The last digit of 105 is ${getLastDigit(105)}`);
1714
console.log(`The last digit of 806 is ${getLastDigit(806)}`);
1815

1916
// Now run the code and compare the output to your prediction
20-
// =============>// The last digit of 42 is 3
21-
// The last digit of 105 is 3
22-
// The last digit of 806 is 3
17+
// =============> write the output here
2318
// Explain why the output is the way it is
24-
// =============> the variable num is assigned to the value 103 in the global scope and not assigned to any value in the function scope
19+
// =============> write your explanation here
2520
// Finally, correct the code to fix the problem
2621
// =============> write your new code here
27-
function getLastDigit(num) { // we add the identier num as parameter to the function getLastDigit
28-
return num.toString().slice(-1);
29-
}
30-
31-
console.log(`The last digit of 42 is ${getLastDigit(42)}`);
32-
console.log(`The last digit of 105 is ${getLastDigit(105)}`);
33-
console.log(`The last digit of 806 is ${getLastDigit(806)}`);
3422

3523
// This program should tell the user the last digit of each number.
3624
// Explain why getLastDigit is not working properly - correct the problem

0 commit comments

Comments
 (0)