Credit Card Checker Project

I am working on the credit card checker project. I think I have the idea logically worked out but for some reason my code is not working. When I run the code below the newArr array is successful in dropping the last digit and reversing the order but it does not multiply every other element in the array, the values stay the same.

function validateCred(array) {
  let newArr = [];
  for (let i = array.length -2 ; i >= 0; i--){
    newArr.push(array[i]);
  }
    newArr.reverse;
  for (let j = 0; j < array.lenth-1; j+=2) {
    if(newArr[j] * 2 > 9){
      newArr[j] = newArr[j] * 2 - 9;
    } else {
      newArr[j] = newArr[j]*2;
    }
  }

   return newArr;

so if I run the code on this array
const valid1 = [4, 5, 3, 9, 6, 7, 7, 9, 0, 8, 0, 1, 6, 8, 0, 8];

I am returned
[ 0, 8, 6, 1, 0, 8, 0, 9, 7, 7, 6, 9, 3, 5, 4 ] as of now which is incorrect.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.