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
// The Error was syntax error as "str" has already been declared and we can't declare it again as variable name. Now I declare a new variable name and assign value.
Copy file name to clipboardExpand all lines: Sprint-2/2-mandatory-debug/2.js
-15Lines changed: 0 additions & 15 deletions
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,6 @@
2
2
3
3
// Predict the output of the following code:
4
4
// =============> Write your prediction here
5
-
// I predicted that it will show undefined or fixed number like 3
6
5
7
6
constnum=103;
8
7
@@ -16,24 +15,10 @@ console.log(`The last digit of 806 is ${getLastDigit(806)}`);
16
15
17
16
// Now run the code and compare the output to your prediction
18
17
// =============> write the output here
19
-
// The last digit of 42 is 3
20
-
// The last digit of 105 is 3
21
-
// The last digit of 806 is 3
22
18
// Explain why the output is the way it is
23
-
// num has fix number which is 3 and i return this fix number
24
19
// =============> write your explanation here
25
-
// user want last digit whatever number they put but i set up a fix number which will return that one that's why now i removed fixed number and wrote a parameter in function
26
-
// which will contain user number whatever number they put and get the last digit.
27
20
// Finally, correct the code to fix the problem
28
21
// =============> write your new code here
29
22
30
-
functiongetLastDigit(num){
31
-
returnnum.toString().slice(-1);
32
-
}
33
-
34
-
console.log(`The last digit of 42 is ${getLastDigit(42)}`);
35
-
console.log(`The last digit of 105 is ${getLastDigit(105)}`);
36
-
console.log(`The last digit of 806 is ${getLastDigit(806)}`);
37
-
38
23
// This program should tell the user the last digit of each number.
39
24
// Explain why getLastDigit is not working properly - correct the problem
0 commit comments