I’m having issues with the first part of the checker. I keep getting false for valid card numbers:
const valid2 = [5, 5, 3, 5, 7, 6, 6, 7, 6, 8, 7, 5, 1, 4, 3, 9];
const validateCred = array => {
const checkDigit = array.pop();
const testArr = array.reverse();
for (let i=0; i<testArr.length; i+=2) {
let doubleNum = testArr[i]*2;
if (doubleNum > 9) {
testArr[i] = doubleNum - 9;
}
}
let arrSum = testArr.reduce((a, b) => a+b, checkDigit);
return arrSum % 10 === 0 ? true : false;
};
console.log(validateCred(valid2));
I’ve been racking my brain trying to figure this out… What am I missing?