Skip to content

Commit ddfce92

Browse files
Fix getLastDigit to accept num parameter
1 parent 352fee7 commit ddfce92

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

  • Sprint-3/2-mandatory-debug

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
// take any parameters — it always uses the outer 'num' variable (103)
88
// instead of the value passed into the function call.
99

10-
const num = 103;
11-
12-
function getLastDigit() {
10+
function getLastDigit(num) {
1311
return num.toString().slice(-1);
1412
}
1513

@@ -25,6 +23,4 @@ console.log(`The last digit of 806 is ${getLastDigit(806)}`);
2523

2624
// Explain why the output is the way it is
2725
// ==============> write your explanation here
28-
// The function getLastDigit() is defined with no parameters, so the values
29-
// 42, 105, and 806 passed into each call are simply ignored — they go
30-
// nowhere. Instead, the
26+
// The function getLastDigit() is defined with no parameter, so the values 42, 105, and 806 passed into each call are simply ignored. Instead, the function always uses the hardcoded const num = 103, so it always returns the last digit of 103, which is 3, no matter what argument is passed in.

0 commit comments

Comments
 (0)