Skip to content

Commit 80bc588

Browse files
committed
Fix card number slicing error
1 parent 0fc0771 commit 80bc588

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

  • Sprint-2/2-mandatory-errors

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
const cardNumber = 4533787178994213;
2-
const last4Digits = cardNumber.slice(-4);
2+
// Convert the number to a string before slicing to get the last four digits.
3+
const last4Digits = String(cardNumber).slice(-4);
4+
console.log(last4Digits);
35

46
// The last4Digits variable should store the last 4 digits of cardNumber
57
// However, the code isn't working

0 commit comments

Comments
 (0)