CHANNELS:

All
a
having trouble creating a character
Canvas
aaliyah403 posted 3 years ago

I followed the code exactly but I keep getting the same error

"Uncaught SyntaxError: Identifier 'player' has already been declared"

I've tried everything and nothing seems to be working

chris posted 3 years ago
Best Reply

Double check that you only have one instance of a player const or let. It might be located in a different file if you're pulling in multiple script tags.

As long as there's only one const player = new Player() your error will go away.

If you need to reset it somewhere else separately, define it as a let and set it without a declaration:

let player = new Player()
player = new Player()
1

Want to participate?

Create a free Chris Courses account to begin

or
Sign In

Providing the lift to launch your development career

© 2025 Chris Courses. All rights reserved.