We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bad8580 commit 8f50754Copy full SHA for 8f50754
Sprint-1/2-mandatory-errors/3.js
@@ -1,5 +1,11 @@
1
+// Prediction: The code will not work because cardNumber is defined as a number not a string.
2
+// The slice method is a string and arrays method, and cannot be used on a number type.
3
+// Error: TypeError: cardNumber.slice is not a function
4
+
5
const cardNumber = 4533787178994213;
-const last4Digits = cardNumber.slice(-4);
6
+const last4Digits = cardNumber.toString().slice(-4);
7
8
+console.log(last4Digits); // Should output: 4213
9
10
// The last4Digits variable should store the last 4 digits of cardNumber
11
// However, the code isn't working
0 commit comments