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 :’)
Hello! If you want to add all the numbers in a list, how would you do that? Forget checking anything for now.
Hint
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:
Think about how you would go about doing the task manually (by hand), then do it (or at least a little bit of it).
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.
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
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.