Credit Card Checker Problem

Hello, I am having some issues at the validateCred function. The issue happens only at “valid3”, “invalid3” and “mystery3” which have a different length compared to the others. Running the code on the 3rd mystery array we get 2x “NAN” values into the array, sending us a negative output. Any help?

Hi Radu,

you’re not checking whether the last digit you are looping over exists or not:

for(let i = 0; i < arr.length; i += 2) 

If the amount of digits in the array is odd, you have the following issue:

array.length = 11
i = 10 // i < array.length --> true
i += 2 // i --> 12
newArr[12] *= 2 // --> NaN