Credit Card Checker Challenge Project (JavaScript)

Hey everyone. Think I got this working :sweat_smile:

Greetings to all from the UK. :slight_smile:

And here’s my funky solution :slight_smile:

1 Like

First time sharing GitHub, but here is the solution to my work:

Took me few hours to complete, but now I’m proud of myself for creating first JS project without looking at hints. Please feel free to check link with my code. Any feedback will be much appreciated.

hi everyone. Here is my solution.


Here I leave my solution for the Challenge Project: Credit Card Checker


Am I the only one with extreme difficulties in this? I cant even do the first step… Should I just quit learning js? :disappointed_relieved: So frustrating


Here is my solution for the Credit Card Checker Challenge. I managed to do the bonus questions, including the invalid to valid card converter. The converter alters the last and the third-last digits to get a valid card to match the algorithm. Feedback is appreciated.

Credit Card Checker Challenge Code


1 Like

Don’t give up. I used to struggle like you.

1 Like

Any advices? Should I go back and do over and over again all the other topics?
Any other places I can learn more? youtube, books?
I really like this and I want to change my career but I’m feeling so frustrated and thinking I’m not smart enough for this :confused:

You might want to go back through the topics again and try to refrain from looking at the solutions from Get Unstuck. For challenges, you might want to look at other sources. I was once told that learning to code is like learning to swim.

Hi! :smile:
I would like to share my solution to this project with you.
Any feedback is welcome c:


Happy Coding!

This took me several days and lots of staring at my screen to figure out, so I’m happy it’s completed. Might not be the cleanest code, but I definitely learned a lot of new terms.

creditcardvalidator/script.js at main · kelfromdablock/creditcardvalidator (


some hopefully helpful tips:

Your line 30 loop
instead of reversing the array and iterating through it, you can set your for loop to the work for you. Also, since it is alternating to double the digit every other element in the array, you can “flip” a boolean by using a !

let sumOfDigits = 0;
toDouble = false;                          // starts false so the check digit isn't doubled
for (let i = arr.length-1; i >= 0; i--) {  // starts at the last element and iterates backwards
    if (toDouble) {
        let digit = arr[i] * 2;            // double the digit
        // reduce by 9 if doubled digit > 9
        let digit = (digit > 9) ? digit - 9 : digit;
    } else {
       let digit = arr[i];                 // don't double
   sumOfDigits += digit;                   // adds to sum
    toDouble = !toDouble;                  // alternates and flips the boolean every loop

Lines 43 - 48
You can use our array iterators we learns instead of looping through it! super convenient
filter returns an array for you, so your multiple lines could be reduced to

// Use ! because the invalid cards result to false, which means they'll be filtered out
function findInvalidCards(invalid) {
  return invalid.filter((card) => !validCred(card));

Thanks for the feedback. I struggled the most around line 30, so I’m not surprised there would be an easier way.

The second tip is very helpful and much cleaner.

Instead of my Boolean !Val flip, you can also check if the index i is even or odd with a modulo like % 2 which will be 0 on items you don’t want to double and 1 on items you will double. These type of things will eventually become second nature, promise!

Here’s my solution! Thinking about doing this project again to try making my code shorter and more efficient

Heyo :wave:,

I just finished the Credit Card Checker Project.

If you wanna look into my code when executed click below.
Here you can find my live GitHub Pages site just visit it and look into the console:

And here you can find my repository and my index.js file to look into my code:

I hope you like my solution and if you have any suggestions for improvement for me after lookin into my code please don’t hesitate to contact me.

Thank you and Happy Coding! :grin:

Here is my solution to the project.
Hope it helps any of you guys.

Also I´m open to your feedback


credit_card_checker/main.js at main · FdelaF/credit_card_checker (