Visual Studio Code issue?

Hey everyone!
I’m currently on visual studio code creating my first project and when I’m declaring 3 arrays carrying 5 different strings each, a syntax error appears on each of the commas, as well as the end bracket. It might be important to add the file is a .js one. Any help at all would be appreciated and the code is the block below:

const Teams = {"Los Angelos Tornado", "Montreal Tigers", "Toronto Strongmen", "Oakville Bears", "Washington Fighters"};
const Positions = {"Wide Receiver", "Quarter Back", "Running Back", "Offensive Linemen", "Defensive Linemen"};
const JerseyName = {"Newman", "Jackson", "Brady", "Rogan", "Obama"};

Not sure whether you’re trying to use Java or JavaScript (I presume the latter, .js is the file extension for JavaScript files).

In JavaScript, arrays are declared using square brackets [].

And just in case, if you’re trying to use Java, then you need the .java file extension and should be declaring the variable type (String[]) rather than using const (which is used to declare constants in JS).

Yep I did mean JavaScript, also I was soo close to trying the square brackets at one point and thought other wise, thank you!

1 Like