Credit Card Checker Challenge Project (JavaScript)

You’re right. I’ve just updated the fuction having in mind what you mentioned and it certainly is easier to read. Thanks a lot.

1 Like

Here’s my solution! Feel free to provide any feedback! :slight_smile:

My version of a solution to this challenge:
https://github.com/gingergaz/codecademy_sharing/raw/main/credit_card_number_checker.js
Hope everyone’s enjoying the course!

I share my own solutions.

Credit Card Checker (GitHub) - lacurnow

Hi all,
I’ve decided to share my solution as it’s a good opportunity to learn how to use GitHub, as well as get some feedback! I completed the additional challenges for extra practice, and in the future I may add functionality to improve the card validity convertor based on the issuing card company (and hence length of card number). Thanks.

Hello everyone, here is a link to a repo holding my credit card project. I will appreciate your constructive criticism and hint to refactor where redundancy is the case. Thank you!

chibike460/Mini-Projects: Some mini/side projects as I reinforce my Full Stack Engineering skills. (github.com)

Here is my repository for the project: GitHub - MadhavMenon1007/Credit-Card-Checker: First Codecademy Project with JavaScript

Please give me any feedback so I can optimise my code. Thank You!

Here is my repository for the project:

Hope this is useful for some users :slight_smile: Any feedback gratefully received.

1 Like

Want to say thank you to every person who was doing this task. I’ve done a lot of mistakes, went through quite a few topics from all over the place.
Biggest tripping stone was invalid card type check.

Best of luck everyone
CreditCardCheker

1 Like

Hi All,

This is my solution. Thank you for sharing yours. It helps me learn a lot.

2 Likes

After seen the Codecademy solution I felt a little bit dumb. Is there any place to look for smart solutions like this backward loop with the even/odd validation for the index? I’ve also felt that maybe I will never come with this kind of solution on my own.

My code used three loops just for the first function, everything works fine, but its not lean as this, so please if anyone could give me tips on how to get things done in a better way, please feel free to comment, here is my link:

best,
Erick

1 Like

Hello, Erick.

Looking at your code, you’ve got nothing to be ashamed of or feel dumb about. You seem to have very thoughtfully and deliberately gone through the steps necessary to solve the challenge. Your code returns the expected output. Great Job! The next step (if you choose to do so) is to refactor. There are many ways to accomplish the validation process. You could work out how to combine one or more of your loops. You could research built in methods that accomplish what your loops are doing. The built in methods may appear more ‘lean’, but they still have to iterate through the original array, so they aren’t necessarily more efficient. You could also approach the problem from a whole new angle. Maybe you could calculate the sum of the digits in the original array without creating any additional arrays. As I’ve progressed in learning, I’ve come back to this project numerous times to refactor my code. I highly suggest doing the same. Applying newly learned concepts to old code is valuable experience. Happy Coding!

A place to start (if you so desire):

//You could combine these two tasks into a single loop:
  for (let i = arr.length -2; i >= 0; i -= 2) {
    checkerArray.push(arr[i] * 2);
  };

  for (let k = 0; k < checkerArray.length; k++) {
    if (checkerArray[k] >= 10) {
      checkerArray[k] = checkerArray[k] - 9;
    };
  };
2 Likes

Thanks for your insights, really appreciate it. The thing is that now that I look at the solution, if I sums up the loop output directly into a variable or use the even/odd index, like codecademy did, feels like I’m copying it, you know? Because I know that stuff, is just I could think in the same way. But I took this last 3 days to breath, I think I overreacted somehow, as soon as I saw the solution the first thought was ‘this is not for me’, ‘I will never think that way’, etc… But now thinking more clearly, researching and reading this forum and others coders, I will continue the journey. I hope my brain starts to think more lean as this became something more trivial.

I will definitely refactor this part with an ‘if’.

best,
Erick

1 Like

Hi! :slight_smile:
My solution GitHub - aroundthailand/credit-card-checker

1 Like

Hi, i link my solution here : feel free to share your insights,
https://gist.github.com/a47383f73e857fdc149ad659bacff51d

thanks.

I wanted to do the findInvalidCards() using filter but couldn’t quite get it how I wanted so ended up doing a loop

I like your findInvalidCards function

I was trying to do something similar using filter but couldn’t quite get it how I wanted

1 Like

Hi, should I share the link here. I don’t know how to share in GitHub

Hello, everyone. I feel my code is a lot and could be trimmed down a bit, but that’s what I could come up it and it works at least.
I look forward to your reviews.

Thank you, buddy! :slight_smile: There are many ways to accomplish the task, so I think your solution is OK too. :slight_smile: