Skip to content

Commit 6349e37

Browse files
committed
fixed the issue of not using String class to convert to string
1 parent 0ba4f94 commit 6349e37

File tree

1 file changed

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

1 file changed

+1
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ const cardNumber = 4533787178994213;
1414
//After running the code, I have realized that the code is not working because cardNumber is a number and the slice is a method in String class
1515
//so, in order to make it work, we need to change cardNumber to String before calling the slice method
1616

17-
const last4Digits = (cardNumber + "").slice(-4);
17+
const last4Digits = String(cardNumber).slice(-4);
1818
console.log("Last four digits of card are : " + last4Digits);

0 commit comments

Comments
 (0)