Skip to content

Commit 4a41676

Browse files
committed
Cleaner code
1 parent 4c474e3 commit 4a41676

File tree

1 file changed

+7
-3
lines changed
  • Sprint-1/2-mandatory-errors

1 file changed

+7
-3
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
const cardNumber = 4533787178994213;
2-
const last4Digits = String(cardNumber).slice(-4);
3-
console.log(last4Digits); //"4213"
1+
//const cardNumber = 4533787178994213;
2+
//const last4Digits = String(cardNumber).slice(-4);
3+
//console.log(last4Digits); //"4213"
4+
5+
// Cleaner code:
6+
const last4Digits = cardNumber.toString().slice(-4);
7+
console.log(last4Digits); // "4213"
48

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

0 commit comments

Comments
 (0)