File tree Expand file tree Collapse file tree
Sprint-2/2-mandatory-errors Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- const cardNumber = " 4533787178994213" ;
2- // const last4Digits = cardNumber.slice(-4);
3- const last4Digits = cardNumber . slice ( - 4 ) ;
1+ const cardNumber = 4533787178994213 ;
2+ const last4Digits = cardNumber . toString ( ) . slice ( - 4 ) ;
3+ // alternatively, const last4Digits = ( cardNumber + '') .slice(-4);
44console . log ( last4Digits ) ;
55
66// The last4Digits variable should store the last 4 digits of cardNumber
@@ -15,3 +15,6 @@ console.log(last4Digits);
1515// Checked the error reference and decided to look more closely. Noticed that the card number is used as a number,
1616// so it answers why the function couldn't be called - because they can be only called on Arrays and Strings.
1717// Therefore, I'll add parentheses to turn the card number into a string (so that the function could be called)
18+
19+ // Fix.
20+
You can’t perform that action at this time.
0 commit comments