Skip to content

Commit a379651

Browse files
committed
fix of get last digit function error
1 parent 5afd460 commit a379651

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

  • Sprint-3/2-mandatory-debug

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
// Predict the output of the following code:
44
// =============> Write your prediction here
5-
//getting the last digit of 103
6-
// const num = 103;
5+
//-getting the last digit of 103
6+
7+
// const num = 103;
78

89
// function getLastDigit() {
910
// return num.toString().slice(-1);
@@ -27,14 +28,14 @@
2728

2829
// This program should tell the user the last digit of each number.
2930
// Explain why getLastDigit is not working properly - correct the problem
30-
//The function was looking at the outside "num" but Now there are two (num) one outside the scope "const num= 103" and i added another inside the function scope.
31-
//The function calculates something and returns it then console.log outside receives that returned value and prints. it.
32-
const num = 103;
31+
//-The function was looking at the outside "num" but Now there are two (num) one outside the scope "const num= 103" and i added another inside the function scope.
32+
//-The function calculates something and returns it then console.log outside receives that returned value and prints it.
33+
34+
const num = 103;
3335

34-
function getLastDigit() {
36+
function getLastDigit(num) {
3537
return num.toString().slice(-1);
3638

37-
// console.log(getLastDigit(42));
3839
}
3940
console.log(`The last digit of 42 is ${getLastDigit(42)}`);
4041
console.log(`The last digit of 105 is ${getLastDigit(105)}`);

0 commit comments

Comments
 (0)