Issue with an 'Challenge Project: Credit Card Checker' project

You must select a tag to post in this category. Please find the tag relating to the section of the course you are on E.g. loops, learn-compatibility

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

'const validateCred = (arr)=>{
let newArray=;
for (var i = arr.length - 1; i >= 0; i–) {
if(i%2==0){
newArray.push(arr[i])
}else{
newArray.push(arr[i]*2)
}
}

console.log(newArray)
}

console.log(valid1)
validateCred(valid1)


The output of my code so far:

Output:

[ 4, 5, 3, 9, 6, 7, 7, 9, 0, 8, 0, 1, 6, 8, 0, 8 ]
[ 16, 0, 16, 6, 2, 0, 16, 0, 18, 7, 14, 6, 18, 3, 10, 4 ]

I am not sure how to subtract -9 once the value in the array is double and greater than 9. Am I going in the right direction? Here is the link to the exercise I am working on.

https://www.codecademy.com/journeys/front-end-engineer/paths/fecj-22-building-interactive-websites/tracks/fecj-22-javascript-syntax-part-ii/modules/wdcp-22-credit-card-checker-354e6ce7-f8d4-4384-a866-8f408d4659ea/projects/credit-card-checker

When you ask a question, don’t forget to include a link to the exercise or project you’re dealing with!

If you want to have the best chances of getting a useful answer quickly, make sure you follow our guidelines about how to ask a good question. That way you’ll be helping everyone – helping people to answer your question and helping others who are stuck to find the question and answer! :slight_smile:

You could make another variable to do that.
In your for-loop, you have

    }else{
      newArray.push(arr[i]*2)
    }

but you could expand that to be

    }else{
      let x = arr[i] * 2;
      if(x > 9){
        x = x - 9;
      }
      newArray.push(x);
    }