Credit card return only false

Hi, i do it this function for verify the valid numbers but return only false. This is the link to credit card checker Card checker

const validateCard = arr => {

    let arrReverse = arr.reverse(); // Reverse the array

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

        if (arr[i] % 2 != 0) {// Chech if element is even

            arrReverse[i] = arrReverse[i] * 2;

            if (arrReverse[i] > 9) {

                arrReverse[i] -= 9;

            }

        }

    }

    let sum = arrReverse.reduce((a, b) => a + b, 0);

    if (sum % 10 == 0) {

        return true;

    } else {

        return false;

    }

}

console.log(validateCard(valid3));

Hello, @woldelewis6026390521, welcome to the forums.

Why are you checking if the element is even?

I checked the element if its even to multiply with 2

To implement the Luhn algorithm, after reversing the array, you want to perform the doubling and subtracting 9 (if necessary) on every other element, correct? So what difference does it make if the element is even or odd. I think perhaps you mean to be checking the index of the element rather than the element itself.

Also, your code is mutating the original array. You’ll want to make a copy of the array, and perform your mutations on the copy.