Credit Card Checker Issue HELP

Hello guys. As you can see below, my first function is working fine but the second one doesnt as intended. Instead of pushing into an array Invalid cards it is giving me a set of numbers which doesnt match with a single array. The instructions are: Create another function, findInvalidCards() that has one parameter for a nested array of credit card numbers. The role of findInvalidCards() is to check through the nested array for which numbers are invalid, and return another nested array of invalid cards. What could be the problem?
link to the project: https://www.codecademy.com/journeys/front-end-engineer/paths/fecj-22-building-interactive-websites/tracks/fecj-22-javascript-syntax-part-ii/modules/wdcp-22-credit-card-checker-354e6ce7-f8d4-4384-a866-8f408d4659ea/projects/credit-card-checker

my gist:

and here is the outcome i am getting:
[ [ 6, 7, 2, 6, 2, 2, 0, 1, 9, 9, 7, 5, 4, 3, 3 ],
[ 8, 5, 6, 2, 5, 7, 7, 7, 5, 1, 0, 9, 2, 7, 9, 5 ],
[ 1, 7, 9, 5, 1, 9, 6, 3, 9, 2, 2, 3, 8, 6, 8, 3 ],
[ 6, 7, 1, 7, 9, 6, 0, 8, 8, 4, 1, 9, 9, 1, 8 ],
[ 3, 0, 2, 1, 2, 2, 5, 9, 3, 1, 5, 7, 5, 9, 6, 5 ],
[ 1, 3, 7, 2, 0, 1, 9, 7, 5, 2, 7, 8, 6, 8, 1, 4 ],
[ 6, 4, 8, 8, 0, 1, 9, 6, 7, 3, 0, 5, 8, 1, 8 ],
[ 8, 9, 4, 9, 7, 7, 5, 1, 3, 9, 4, 1, 5, 0, 9, 3 ] ]

Two things:

  1. Check the output for validateCred(valid3) - it returns false, but should be true.

  2. You need to create a temporary array in validateCred() - the array gets mutated in the function, so that is why your output for findInvalidCards() is wonky. (Hint… use slice())

2 Likes

Dear James,
Thank you so much for your help, the slice solution solved the problem with the second function. However, the first function still finds the valid3 array as false. I have inspected my code many times, however, cant find the reason. What could be the reason?

Dear James,
I found the problem. there are only 15 numbers in the Valid3 array instead of 16. Everything is working correctly, however, is it supposed to be like that?

1 Like

Hey @userfara,

Yes, the array is supposed to be only 15 numbers. This is part of the challenge, you need your function to determine if it’s valid even when the card has a different amount of numbers.

Well done!