There was an error while loading. Please reload this page.
1 parent 214738f commit 3e94e97Copy full SHA for 3e94e97
1 file changed
Sprint-2/2-mandatory-errors/3.js
@@ -1,5 +1,5 @@
1
-const cardNumber = '4533787178994213';
2
-const last4Digits = cardNumber.slice(-4);
+const cardNumber = 4533787178994213;
+const last4Digits = cardNumber.toString().slice(-4);
3
4
console.log(last4Digits)
5
@@ -10,4 +10,5 @@ console.log(last4Digits)
10
// Consider: Why does it give this error? Is this what I predicted? If not, what's different?
11
// Then try updating the expression last4Digits is assigned to, in order to get the correct value
12
13
-//slice is for text or array only. Need to change card number from number to text. Add ''for 4533787178994213.
+//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