Skip to content

Commit e6a26fd

Browse files
committed
Change the expression last4Digits is assigned to
1 parent 5b83030 commit e6a26fd

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

  • Sprint-2/2-mandatory-errors

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
const cardNumber = "4533787178994213";
2-
//const last4Digits = cardNumber.slice(-4);
3-
const last4Digits = cardNumber.slice(-4);
1+
const cardNumber = 4533787178994213;
2+
const last4Digits = cardNumber.toString().slice(-4);
3+
// alternatively, const last4Digits = (cardNumber + '').slice(-4);
44
console.log(last4Digits);
55

66
// The last4Digits variable should store the last 4 digits of cardNumber
@@ -15,3 +15,6 @@ console.log(last4Digits);
1515
// Checked the error reference and decided to look more closely. Noticed that the card number is used as a number,
1616
// so it answers why the function couldn't be called - because they can be only called on Arrays and Strings.
1717
// Therefore, I'll add parentheses to turn the card number into a string (so that the function could be called)
18+
19+
// Fix.
20+

0 commit comments

Comments
 (0)