I'm trying to write a game in javascript, and I want to have an array of size 16 that I can update and return in different functions. Here's what I have so far, and why it isn't working.
function startgame(){
var status = new Array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
console.log(status.length);
return status;
}
var status = startgame();
console.log("status length now: "+ status.length);
As expected, the first log inside the function shows 16. However, the second one after the function call says "status length now: 31". The returned array is counting all the commas. How can I avoid this?