Skip to content

Commit 7ec6995

Browse files
committed
explained why my prediction was wrong
1 parent f920359 commit 7ec6995

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

  • Sprint-2/2-mandatory-errors

‎Sprint-2/2-mandatory-errors/3.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@ const last4Digits = cardNumber.slice(-4);
1010
// Then try updating the expression last4Digits is assigned to, in order to get the correct value
1111

1212
// 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-
13+
//console.log(last4Digits)
14+
//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.

0 commit comments

Comments
 (0)