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 6697426 commit 61fd838Copy full SHA for 61fd838
Sprint-1/2-mandatory-errors/3.js
@@ -1,5 +1,10 @@
1
const cardNumber = 4533787178994213;
2
-const last4Digits = cardNumber.slice(-4);
+// Prediction: The code will not work because the `slice` method is being called on a number type (`cardNumber`),
3
+// and the `slice` method is a string method. In JavaScript, numbers do not have a `slice` method.
4
+// Running the code will likely result in a TypeError.
5
+
6
+const last4Digits = cardNumber.toString().slice(-4); // Convert cardNumber to a string first
7
+console.log(`The last 4 digits of the card number are ${last4Digits}`);
8
9
// The last4Digits variable should store the last 4 digits of cardNumber
10
// However, the code isn't working
0 commit comments