Javascript Error reporting variable already declared

I created an example of a simply particle system after watching one of Dan Shiffman’s video. However it gives an error “Uncaught SyntaxError: Identifier ‘location’ has already been declared (sketch: line 1)” which make no sense.

Arguments named location have been used in the constructors of both the Particle and ParticleSystem classes however these are local to those classes so I am not sure why it’s reporting that the variable has already been declared. Changing the name of the variable in sketch.js to “loc” solved the problem but shouldn’t be necessary.

The link to the sketch with the error is: https://editor.p5js.org/learntocodebb/sketches/xGX17bqPA

1 Like
2 Likes

Thank you. I guess I have never named a variable location before. lol