I'm trying to run a function on each array within an array, however it only seems to run the iteration once, i dont get any error messages to help me figure out why?
its a basic credit card checker project
// An array of all the arrays above
const batch = [valid1, valid2, valid3, valid4, valid5, invalid1, invalid2, invalid3, invalid4, invalid5, mystery1, mystery2, mystery3, mystery4, mystery5];
// Add your functions below:
const validateCred = (arr) =>{
let totalSum = 0
let newArr = arr.slice(0);
let lastDigit = newArr.pop()
newArr = newArr.reverse()
for(i = 0; i < newArr.length; i++){
if (i % 2 === 0){
let doubled = newArr[i] * 2
if (doubled > 9){
doubled -= 9
}
totalSum += doubled
} else {
totalSum += newArr[i]
}
}
if((totalSum + lastDigit) % 10 === 0){
return true
} else {
return false
}
};
const findInvalidCards = (arrBatch) =>{
let invalidCred = []
for(i = 0; i<arrBatch.length; i++){
console.log(validateCred(arrBatch[i]))
}
};
findInvalidCards(batch);```