Skip to content

Commit 3e94e97

Browse files
committed
modified the answer of 2-mandatory-errors 3.js
1 parent 214738f commit 3e94e97

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

  • Sprint-2/2-mandatory-errors

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const cardNumber = '4533787178994213';
2-
const last4Digits = cardNumber.slice(-4);
1+
const cardNumber = 4533787178994213;
2+
const last4Digits = cardNumber.toString().slice(-4);
33

44
console.log(last4Digits)
55

@@ -10,4 +10,5 @@ console.log(last4Digits)
1010
// Consider: Why does it give this error? Is this what I predicted? If not, what's different?
1111
// Then try updating the expression last4Digits is assigned to, in order to get the correct value
1212

13-
//slice is for text or array only. Need to change card number from number to text. Add ''for 4533787178994213.
13+
//slice is for text or array only. Need to change card number from number to text. use toString() to convert cardNumber
14+
//from integer to string.

0 commit comments

Comments
 (0)