Credit card checker function

I need help with my credit card checker. I can’t get to spit out the valid1 array after doing modulo for x = i % 2;
here is some of my code.
Please help
const validateCred = (num) => {
for (i = 0; i < valid1.length; i++){
x = valid1;
x = i % 2;
if (x !== 0){
return x;
}
}
}
console.log(validateCred());

Hey @micro3769222521,

We are here to help :wink: .

But I do have a question first, how far are you with the Javascript courses? Looking at your code I can see you have some knowledge but other aspects make me ask the above question.

I am currently 49% finished. I do know there are some concepts that I need help on. My main concern is learning how to do word problems in codecademy. Thanks for the help.

Nevermind. I think I figured it out (and corrected the code as well).

If you are having trouble, please use my code as a reference! I am proud to say I did this on my own and want you to have something to work off of if you are stuck! Enjoy and continue on your coding journey! Please don’t hesitate to contact me or anyone if you have any questions!

1 Like

Congratulations on solving it. I have no idea where you got that code :slight_smile: im stuck but dont want to use your Code, I would like to understand it. If you have the time to help me.

I was looking at your code again and I don’t understand this line

for(let i = array.length - 1; i >= 0; i -= 2) {
checkDigits.push(array[i]);
}

can you help me?

hello, I seem to be hitting a wall too. 1) I’m vague where to start. I keep on printing out valid1.pop and valid1. reverse but that is it then I have a loop

validateCred = (isValid) => {
for (let i = 0; i <= valid1.length -1; i++) {
//then nothing.
}
I have gone back over javaScript loops again.

Thanks

figured it out, Thanks