Credit Card Checker Challenge Project (JavaScript)

Hello, fellows. This is my little contribution. I know it doesn’t look so clean, but it’s functional.

hi! check my solution with array methods

Hello,

I have finished the credit card Checker project. If anyone would like to check it out and give feedback that would be greatly appreciated. I haven’t created or received a pull request before. So if you would like to try out these functions with me, let’s explore these functions together. Identify-invalid-Credit-Card-Reader

Cheers,
Katherine

1 Like

Hello everybody,

just wanted to share my solution.

Thanks

FINALLY!! finished the creditcardChecker! And I’m really proud tbh! Can’t believe I actually made it!

First solution for the Credit Card Checker. Would love to see simpler and more concise approaches to this project!

Here is my solution for the credit card numbers checker. any constructive criticism would be greatly appreciated

Thanks you in advance.

Hi guys,

This is my code for the javascript project: Challenge Project: Credit Card Checker

thnx

Here is my Solution for the credit card PROJEKT!!!

// All valid credit card numbers
const valid1 = [4, 5, 3, 9, 6, 7, 7, 9, 0, 8, 0, 1, 6, 8, 0, 8];
const valid2 = [5, 5, 3, 5, 7, 6, 6, 7, 6, 8, 7, 5, 1, 4, 3, 9];
const valid3 = [3, 7, 1, 6, 1, 2, 0, 1, 9, 9, 8, 5, 2, 3, 6];
const valid4 = [6, 0, 1, 1, 1, 4, 4, 3, 4, 0, 6, 8, 2, 9, 0, 5];
const valid5 = [4, 5, 3, 9, 4, 0, 4, 9, 6, 7, 8, 6, 9, 6, 6, 6];

// All invalid credit card numbers
const invalid1 = [4, 5, 3, 2, 7, 7, 8, 7, 7, 1, 0, 9, 1, 7, 9, 5];
const invalid2 = [5, 7, 9, 5, 5, 9, 3, 3, 9, 2, 1, 3, 4, 6, 4, 3];
const invalid3 = [3, 7, 5, 7, 9, 6, 0, 8, 4, 4, 5, 9, 9, 1, 4];
const invalid4 = [6, 0, 1, 1, 1, 2, 7, 9, 6, 1, 7, 7, 7, 9, 3, 5];
const invalid5 = [5, 3, 8, 2, 0, 1, 9, 7, 7, 2, 8, 8, 3, 8, 5, 4];

// Can be either valid or invalid
const mystery1 = [3, 4, 4, 8, 0, 1, 9, 6, 8, 3, 0, 5, 4, 1, 4];
const mystery2 = [5, 4, 6, 6, 1, 0, 0, 8, 6, 1, 6, 2, 0, 2, 3, 9];
const mystery3 = [6, 0, 1, 1, 3, 7, 7, 0, 2, 0, 9, 6, 2, 6, 5, 6, 2, 0, 3];
const mystery4 = [4, 9, 2, 9, 8, 7, 7, 1, 6, 9, 2, 1, 7, 0, 9, 3];
const mystery5 = [4, 9, 1, 3, 5, 4, 0, 4, 6, 3, 0, 7, 2, 5, 2, 3];

// An array of all the arrays above
const batch = [valid1, valid2, valid3, valid4, valid5, invalid1, invalid2, invalid3, invalid4, invalid5, mystery1, mystery2, mystery3, mystery4, mystery5];

// Add your functions below:
const validateCred = (Num) => {
  var sum = 0
  for (let i= Num.length - 1; i >= 0; i --){
   if ( i % 2 == 0) 
    { if ((Num[i] * 2) > 9) 
      {var sum = sum + (Num[i] * 2) - 9
      } else
      { var sum = sum + Num[i] * 2}
    } else {  
      var sum = sum + Num[i];
      } 
   }  
let check = sum % 10
if (check === 0){ return true }else {false};
};

var falsecardnum = [];
var correctcardnum = [];
const findInvalidCards = cards => {
for (let i = 0; i < cards.length; i++) { 
    if (validateCred(cards[i]) === true) {
         falsecardnum.push(cards[i])} else {
         correctcardnum.push(cards[i]);  
      };
    } 
};
findInvalidCards(batch);
const idInvalidCardCompanies = falsecardnum => {
  var CreditCardCompanie = []
  for (let i = 0; i < falsecardnum.length; i++){
    if (falsecardnum[i][0] === 3) {
      CreditCardCompanie.unshift('Amex(AmericanExpress)') 
    } else if (falsecardnum[i][0] === 4) {
      CreditCardCompanie.unshift('Visa)') 
    } else if (falsecardnum[i][0] === 5) {
      CreditCardCompanie.unshift('Mastercard)') 
    } else if (falsecardnum[i][0] === 6) {
      CreditCardCompanie.unshift('Discover') 
    } else  {
      CreditCardCompanie.unshift('Company not found') 
    }
  } 
  var mySet = [new Set(CreditCardCompanie)]
  console.log(mySet)
};

idInvalidCardCompanies(falsecardnum)

9 posts were split to a new topic: The correct sum of the doubled array is 29

Hello! I created two files for this project.
The first is where I left my own approach on some problems credit-card-checker/my-version.js at main · makarovangelika/credit-card-checker · GitHub
And the second is where I used recommendations from the hints credit-card-checker/version-from-hint.js at main · makarovangelika/credit-card-checker · GitHub

Hi guys,

This is my code for the Credit Card Checker project

Codecademy Credit Card Checker

Hello everyone
Here is my solution for this project. I used two loops in order to implement the Luhn algorithm! is it a good practice?
please let me know what you think, any comments and suggestions are welcome.

Thank you

Here’s my code! Looking forward to looking through your solutions to see how it compares :slight_smile: