Skip to content

Commit ced4d8c

Browse files
authored
added an extra function to turn the card number into a string
Changed cardNumber to a string before slicing to get last 4 digits.
1 parent 8e9765f commit ced4d8c

File tree

1 file changed

+9
-1
lines changed
  • Sprint-1/2-mandatory-errors

1 file changed

+9
-1
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1+
//const cardNumber = 4533787178994213;
2+
//const last4Digits = cardNumber.slice(-4);
3+
14
const cardNumber = 4533787178994213;
2-
const last4Digits = cardNumber.slice(-4);
5+
const last4Digits = String(cardNumber).slice(-4);
6+
7+
//My prediction was the long card number isn't a string so js will assume it's a variable
8+
//Error given: cardNumber.slice is not a function
9+
//added String function
10+
311

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

0 commit comments

Comments
 (0)