Skip to content

Commit 71fe9f0

Browse files
committed
done 2.js
1 parent e307d6b commit 71fe9f0

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Sprint-2/debug/2.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
11
// Predict and explain first...
22

3+
/*
4+
we can not run this function because we settle the variable with const and this won't allow us to reassign
5+
the new value which we are trying to test in the console.log()
6+
37
const num = 103;
48
59
function getLastDigit() {
610
return num.toString().slice(-1);
711
}
812
13+
*/
14+
15+
//=========== This will work ==============
16+
17+
function getLastDigit(num) {
18+
return num.toString().slice(-1);
19+
}
20+
21+
922
console.log(`The last digit of 42 is ${getLastDigit(42)}`);
1023
console.log(`The last digit of 105 is ${getLastDigit(105)}`);
1124
console.log(`The last digit of 806 is ${getLastDigit(806)}`);

0 commit comments

Comments
 (0)