Skip to content

Commit 529c598

Browse files
updated the code to use type conversion
1 parent 4260fda commit 529c598

File tree

1 file changed

+3
-2
lines changed
  • Sprint-1/2-mandatory-errors

1 file changed

+3
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
const cardNumber = "4533787178994213";
2-
const last4Digits = cardNumber.slice(-4);
1+
const cardNumber = 4533787178994213;
2+
const last4Digits = String(cardNumber).slice(-4);
33

4+
console.log(last4Digits);
45

56

67
//it won't work because slice() works on strings and arrays not on numbers

0 commit comments

Comments
 (0)