Skip to content

Commit b503934

Browse files
uncomment solution for exercies 2.js
1 parent 7947510 commit b503934

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

  • Sprint-3/2-mandatory-debug

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55

66
const num = 103;
77

8-
function getLastDigit() {
9-
return num.toString().slice(-1);
10-
}
8+
// function getLastDigit() {
9+
// return num.toString().slice(-1);
10+
// }
1111

12-
console.log(`The last digit of 42 is ${getLastDigit(42)}`);
13-
console.log(`The last digit of 105 is ${getLastDigit(105)}`);
14-
console.log(`The last digit of 806 is ${getLastDigit(806)}`);
12+
// console.log(`The last digit of 42 is ${getLastDigit(42)}`);
13+
// console.log(`The last digit of 105 is ${getLastDigit(105)}`);
14+
// console.log(`The last digit of 806 is ${getLastDigit(806)}`);
1515

1616
// Now run the code and compare the output to your prediction
1717
// =============> write the output here :output
@@ -20,16 +20,16 @@ console.log(`The last digit of 806 is ${getLastDigit(806)}`);
2020
The last digit of 806 is 3
2121
*/
2222
// Explain why the output is the way it is
23-
// =============> write your explanation here: The funtion return on single value (3) no matter what parameter is passed to it because the function does not take any parameters and it is using the gobal variable num which is set to 103. So the last digit of 103 is always 3.
23+
// =============> write your explanation here: The funtion return one single value (3) no matter what parameter is passed to it because the function does not take any parameters and it is using the gobal variable num which is set to 103. So the last digit of 103 is always 3.
2424
// Finally, correct the code to fix the problem
2525
// =============> write your new code here
2626

27-
// function getLastDigit(num) {
28-
// return num.toString().slice(-1);
29-
// }
30-
// console.log(`The last digit of 42 is ${getLastDigit(42)}`);
31-
// console.log(`The last digit of 105 is ${getLastDigit(105)}`);
32-
// console.log(`The last digit of 806 is ${getLastDigit(806)}`);
27+
function getLastDigit(num) {
28+
return num.toString().slice(-1);
29+
}
30+
console.log(`The last digit of 42 is ${getLastDigit(42)}`);
31+
console.log(`The last digit of 105 is ${getLastDigit(105)}`);
32+
console.log(`The last digit of 806 is ${getLastDigit(806)}`);
3333

3434
// This program should tell the user the last digit of each number.
3535
// Explain why getLastDigit is not working properly - correct the problem : The first declaration of num as constent should be removed and the function getLastDigit should take a parameter num to return the last digit of the number passed to it.

0 commit comments

Comments
 (0)