Skip to content

Commit e6db536

Browse files
committed
Fix card number assignment to string for correct slicing of last 4 digits
1 parent 63265cb commit e6db536

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

  • Sprint-1/2-mandatory-errors

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,16 @@ const last4Digits = cardNumber.slice(-4);
77
// Then run the code and see what error it gives.
88
// Consider: Why does it give this error? Is this what I predicted? If not, what's different?
99
// Then try updating the expression last4Digits is assigned to, in order to get the correct value
10+
11+
PREDICTION:
12+
//the code wont work because the card number isnt in ("") and the computer wont be able to apply the .slice due to this.
13+
14+
THE ERROR:
15+
//cardNumber.slice is not a function
16+
17+
//YES! the error is what i predicted.
18+
19+
FIX:
20+
const cardnumber = "4533787178994213";
21+
const last4Digits = cardnumber.slice(-4);
22+
console.log(last4Digits);

0 commit comments

Comments
 (0)