You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Sprint-3/2-mandatory-debug/2.js
+8-7Lines changed: 8 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -2,8 +2,9 @@
2
2
3
3
// Predict the output of the following code:
4
4
// =============> 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;
7
8
8
9
// function getLastDigit() {
9
10
// return num.toString().slice(-1);
@@ -27,14 +28,14 @@
27
28
28
29
// This program should tell the user the last digit of each number.
29
30
// 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
-
constnum=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
+
constnum=103;
33
35
34
-
functiongetLastDigit(){
36
+
functiongetLastDigit(num){
35
37
returnnum.toString().slice(-1);
36
38
37
-
// console.log(getLastDigit(42));
38
39
}
39
40
console.log(`The last digit of 42 is ${getLastDigit(42)}`);
40
41
console.log(`The last digit of 105 is ${getLastDigit(105)}`);
0 commit comments