I'm trying to make a class GameState with a constructor function to assign my variables. I keep getting the error: Uncaught SyntaxError: Unexpected token 'class' - but all of the documentation I can find says to do it this way. I'm not sure what's wrong. MDN Reference: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/constructor
I also found this solution on stack overflow which also looks like what I have, but I'm still getting an error. ES6 Classes: Unexpected token in script?
I tried commenting out all of my code and pasting an example from MDN and it is throwing the same error https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/class
Could someone please help me out? I'm pretty new to programming but all of the documentation looks right, I'm still lost. Code below for reference.
class GameState {
constructor() {
this.board = [null, null, null, null, null, null, null, null, null];
this.whoseTurn = 1;
this.winner = null;
}
}
let gs = new GameState();