Credit Card Checker (JS)

Hi everyone, I am trying to work through the credit card challenge project and I am really not sure how to go about it, some guidance would be appreciated :’)

// Add your functions below:
function validateCred ()=> {};
validateCred.splice(-1, 1);
const digit=(1,3,5,7,9);
const newDigit=(digit-9);

for(let digit=0; digit< 13; --digit){ 
    return digit * 2;
      if (digit *2 > 9){
        return newDigit;
  if(newDigit + ????? % 10 === 0){


I am basically stuck at summing up all the numbers, your advice would be helpful :pray:

Hello! If you want to add all the numbers in a list, how would you do that? Forget checking anything for now.


Remember how you print out each element in an array using a for loop? Well, would something similar work here? But maybe without the console.log(), and with a variable += iteratingVar.

Once you’ve done that, you should be able to find a way to compare that to whatever it is you want to compare it to.

A good way to go about coding something you have no idea how to do

There are three main steps:

  1. Think about how you would go about doing the task manually (by hand), then do it (or at least a little bit of it).
  2. Think of what you did, and write instructions on how to do it, as though you were going to give them to someone else to use to work on the same task. Try and make them as close to (at least sounding like) code as you can. Use words like for every this in the list xyz…. This is called pseudo-code.
  3. Turn this pseudo-code into real code.
1 Like

thank you for the tips! wouldn’t I need to define variable += iteratingVar? how does the code know what ‘variable’ is? I feel like the element I am missing in my code is incorporating an array ( of the card arrays) into my code. Even if I were to declare it I am not sure how to.

I did a flow chart before I started however my problem is translating that into JS and proper syntax, still working at it :sweat_smile:

You would need to define it, Codeneutrino is just providing a generic example.

You might be onto something here. Think about what data your validateCred function might need - what is it checking and validating? The credit card numbers are declared for you and the directions say not to mutate them.

1 Like