Skip to content

Commit 8436a8a

Browse files
authored
Fix last4Digits assignment to use negative slice index
1 parent 4d1e5f1 commit 8436a8a

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

  • Sprint-1/2-mandatory-errors

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,5 @@ const cardNumber = 4533787178994213;
88
// Consider: Why does it give this error? Is this what I predicted? If not, what's different?
99
// Then try updating the expression last4Digits is assigned to, in order to get the correct value
1010

11-
// [ChunYanWong] The slice method extract substring starting with the first parameter position
12-
// There is no -4 starting position and hence it will not work
1311

14-
const last4Digits = cardNumber.toString().slice(cardNumber.toString().length - 4)
12+
const last4Digits = cardNumber.toString().slice(-4)

0 commit comments

Comments
 (0)