Skip to content

Commit 7fdd13f

Browse files
committed
Fix extracting last 4 digits from card number
1 parent 64003b5 commit 7fdd13f

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

  • Sprint-2/2-mandatory-errors

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
const cardNumber = 4533787178994213;
22
const last4Digits = cardNumber.slice(-4);
33

4+
const cardNumber = "4533787178994213";
5+
const last4Digits = cardNumber.slice(-4);
6+
console.log(last4Digits)
7+
48
// The last4Digits variable should store the last 4 digits of cardNumber
59
// However, the code isn't working
610
// Before running the code, make and explain a prediction about why the code won't work
11+
slice() not work with number
712
// Then run the code and see what error it gives.
13+
cardNumber.slice is not a function
814
// Consider: Why does it give this error? Is this what I predicted? If not, what's different?
915
// Then try updating the expression last4Digits is assigned to, in order to get the correct value

0 commit comments

Comments
 (0)