Skip to content

Commit c929c3c

Browse files
committed
Completed 2.js exercise
1 parent 4bf3376 commit c929c3c

File tree

1 file changed

+8
-2
lines changed
  • Sprint-2/2-mandatory-debug

1 file changed

+8
-2
lines changed

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
// Predict the output of the following code:
44
// =============> Write your prediction here
55

6+
// It will convert 103 number into a String representation and then will either do no manipulations or invert the string
7+
68
const num = 103;
79

8-
function getLastDigit() {
9-
return num.toString().slice(-1);
10+
function getLastDigit(digit) {
11+
return digit.toString().slice(-1);
1012
}
1113

1214
console.log(`The last digit of 42 is ${getLastDigit(42)}`);
@@ -22,3 +24,7 @@ console.log(`The last digit of 806 is ${getLastDigit(806)}`);
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
27+
28+
// The function getLastDigit() has no parameters and referenced a globally scoped constant `num`.
29+
// In order for it to `work properly`, a parameter is required and referencing it in order to
30+
// return an expected value

0 commit comments

Comments
 (0)