I’m stuck with this project.

My code modifies the original (input) array.

Can someone please tell me why and what I am doing wrong.

Each time I call validateCred(valid1), valid1.length is reduced by one.

const valid1 = [4, 5, 3, 9, 6, 7, 7, 9, 0, 8, 0, 1, 6, 8, 0, 8];

const validateCred = (cardNumArr) => {

let inputArr = cardNumArr;

let popNum = inputArr.pop();

let reverseArr = inputArr.reverse();

let checkArr = ;

for (let i=0; i < reverseArr.length; i++) {

if (i % 2 === 0) {

if (reverseArr[i] * 2 > 9) {

checkArr.push(reverseArr[i] * 2 - 9);

} else {

checkArr.push(reverseArr[i] * 2);

}

} else {

checkArr.push(reverseArr[i]);

}

}

checkArr.push(popNum);

checkArr = checkArr.reduce((total, num) => {

return total + num;

});

return (checkArr % 10 === 0);

};