How are you? I'm practicing some JavaScript, since I'm new to it, and I'm trying to create a "space invaders" game with p5.js. I have made some progress, but, I have encountered a problem that I can not solve:
var ship;
var aliens = [];
var missiles = [];
...
...
function keyPressed() {
if (key === ' ') {
var missiles = new missile (width/2, height/2);
missiles.push(missile)
When I try to test by pressing the space bar, it tells me the following:
It is assumed that when you press the spacebar, the code adds a new element to the missiles array, but why does it throw that error?