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 8ab1e36 commit 50f1a25Copy full SHA for 50f1a25
1 file changed
Sprint-1/2-mandatory-errors/3.js
@@ -1,5 +1,5 @@
1
const cardNumber = 4533787178994213;
2
-const last4Digits = cardNumber.toString().slice(-4);
+const last4Digits = Number(cardNumber.toString().slice(-4));
3
4
// The last4Digits variable should store the last 4 digits of cardNumber
5
// However, the code isn't working
@@ -12,4 +12,5 @@ const last4Digits = cardNumber.toString().slice(-4);
12
// I predict an error will happen because cardNumber is a number and not a string and slice can not be used for pure numbers.
13
// We can fix it by turning the number into a string by using .toString() before we slice it.
14
15
-console.log("The last four digits are: " + last4Digits);
+console.log("The last four digits are: " + last4Digits);
16
+console.log("This is a " + typeof last4Digits)
0 commit comments