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
// The last4Digits variable should store the last 4 digits of cardNumber
6
5
// However, the code isn't working
7
6
// Before running the code, make and explain a prediction about why the code won't work
8
7
// Then run the code and see what error it gives.
9
8
// Consider: Why does it give this error? Is this what I predicted? If not, what's different?
10
9
// Then try updating the expression last4Digits is assigned to, in order to get the correct value
11
10
12
-
// I predict that it'll throw a syntax error as its not wrapped in "" so it's registering as a number and but it needs to be a string so the .slice() method can register each individual number in last4Digits?
11
+
// I predict that it'll throw a syntax error as its not wrapped in "" so it's registering as a number and but it needs to be a string so the .slice() method can register each individual number in last4Digits?
13
12
//console.log(last4Digits)
14
13
//output: TypeError: cardNumber.slice is not a function
15
-
//it's slightly different to what i expected as i thought it was solely about not using the right syntax but it's a type error which after research type error is about not being able to perform a certain operation on a value so here the slice method wouldn't work as .slice() method can only work on strings and arrays so i need to turn cardNumber into a string before the slice() method can work on it. so whilst i was right that it needed "" my reason for why was wrong.
14
+
//it's slightly different to what i expected as i thought it was solely about not using the right syntax but it's a type error which after research type error is about not being able to perform a certain operation on a value so here the slice method wouldn't work as .slice() method can only work on strings and arrays so i need to turn cardNumber into a string before the slice() method can work on it. so whilst i was right that it needed "" my reason for why was wrong.
0 commit comments