Credit Card Checker Project

I had the idea to do the following for the idInvalidCardCompanies function, but I get “SyntaxError: Unexpected Token: {” when trying. Why?

The instructions for this function are as follows:

After finding all the invalid credit card numbers, it’s also necessary to identify the credit card companies that have possibly issued these faulty numbers. Create a function, idInvalidCardCompanies() that has one parameter for a nested array of invalid numbers and returns an array of companies.

Currently, there 4 accepted companies which each have unique first digits. The following table shows which digit is unique to which company:

First Digit Company
3 Amex (American Express)
4 Visa
5 Mastercard
6 Discover

If the number doesn’t start with any of the numbers listed, print out a message like: “Company not found”.

idInvalidCardCompanies() should return an array of companies that have mailed out cards with invalid numbers. This array should NOT contain duplicates, i.e. even if there are two invalid Visa cards, "Visa" should only appear once in the array.

My attempted implementation:

function idInvalidCardCompanies(ccNumbers) {
	let companies = {
		3: 'Amex (American Express)',
		4: 'Visa',
		5: 'Mastercard',
		6: 'Discover'

	let companiesFound = [];

	for (let ccNumber of ccNumbers) {
		let firstDigit = ccNumber[0];
		if (firstDigit in companies && !companiesFound.includes(companies[firstDigit]) {

	return companiesFound;

Okay, I spotted my error. I was neglecting to close the conditional parentheses. The parentheses of the .includes method were throwing me off. Now I just have to make sure the code actually does what I want it to…