You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Sprint-1/2-mandatory-errors/3.js
+7-1Lines changed: 7 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,11 @@
1
1
constcardNumber=4533787178994213;
2
-
constlast4Digits=cardNumber.slice(-4);
2
+
constlast4Digits=cardNumber.toString().slice(-4);
3
+
4
+
// Prediction: the second vairable assignemment will give an error because the slice method canno be used on a number. we will get a type error
5
+
6
+
//when i ran the code a got an error saying cardNumber.slice is not a function. this is because the slice method only works on strings and arrays whilst cardNumber is a number.
7
+
8
+
console.log(last4Digits);
3
9
4
10
// The last4Digits variable should store the last 4 digits of cardNumber
0 commit comments