Credit Card Checker Challenge Project (JavaScript)

Hey guys, just completed the Credit Card Checker Challenge Project. Please see my code below:

Any feedback and/or constructive criticism is welcome. :slight_smile:

This response in particular had made it all makes sense to me. Thank you so much

Here is my final solution :innocent:

Hey, I just finished the credit card checker challenge project. If anyone has a bit of time at please can you look over it and give me any tips or pointers on things I could have done differently or better. Thanks

Hey guys, I just finished the credit card checker project. Could anyone give me some feedback on my solution :slight_smile: ? I had some trouble with the idInvalidCompanies function on line 101.
console.log(idInvalidCompanies([invalid1])) is logging Amex, Mastercard, Discover instead of Visa.
Thank you so much!

Your if statements are not nested corrected in the idInvalidCompanies function.
You have:

  invalidNumbers.forEach((number) => {
    if (number[0] === 4) {
    } else if (!companies.includes("Visa") ) {
      companies.push("Visa");
    }
    if (number[0] === 3) {
    } else if (!companies.includes("Amex") ) {
      companies.push("Amex");
    }
    if (number[0] === 5) {
    } else if (!companies.includes("Mastercard")) {
      companies.push("Mastercard");
    }
    if (number[0] === 6) {
    } else if (!companies.includes("Discover")) {
      companies.push("Discover");
    }
  });

but checking whether the array already includes stuff should be inside the other if-block.

  invalidNumbers.forEach((number) => {
    if (number[0] === 4) {
      if (!companies.includes("Visa") ) {
        companies.push("Visa");
      }
    }
    else if (number[0] === 3) {
      if (!companies.includes("Amex") ) {
        companies.push("Amex");
      }
    }
    else if (number[0] === 5) {
      if (!companies.includes("Mastercard")) {
        companies.push("Mastercard");
      }
    }
    else if (number[0] === 6) {
      if (!companies.includes("Discover")) {
        companies.push("Discover");
      }
    }
  });