Skip to content

Commit 2fd1da4

Browse files
committed
Implement getLastDigit function to return the last digit of a number and update console log outputs
1 parent 7d17723 commit 2fd1da4

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

  • Sprint-3/2-mandatory-debug

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,13 @@
2828
// Finally, correct the code to fix the problem
2929
// =============> write your new code here
3030

31+
function getLastDigit(n){
32+
return n.toString().slice(-1)
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+
3139
// This program should tell the user the last digit of each number.
3240
// Explain why getLastDigit is not working properly - correct the problem

0 commit comments

Comments
 (0)