I'm using Spider Monkey to make a simple console chess game.
However I keep getting the error SyntaxError: missing : after property id:
in my enum declaration.
SyntaxError: missing : after property id:
ChessPiece.js:4:5 var Color = {
ChessPiece.js:4:5 ............^
Heres the full code
class ChessPiece
{
var Color = {
WHITE : 'W',
BLACK : 'B'
};
var Piece = {
PAWN : 'P',
ROOK : 'R',
KNIGHT : 'N',
BISHOP : 'B',
QUEEN : 'Q',
KING : 'K'
};
constructor(color, piece)
{
this.color = color;
this.piece = piece;
}
toString()
{
return this.color + this.piece;
}
}
Edit: Updated enum syntax as var declaration.