javascript: array with unknown length and unknown index names
<p>I am making a program of a football league.</p>

<p>A example of a league:</p>

<p>team1
team2
team3</p>

<p>I want to save (increase) number of players for each team like</p>

<pre><code>var teamArray = [];
teamArray[team1] = 1;
teamArray[team2] = 2;
</code></pre>

<p>and I am doing in the body of some functions like:</p>

<pre><code>function 1(){}
function 2(){}
function .(){}
function .(){}
function .(){}
function n(){}
</code></pre>

<p>but this works only when i "teach" javscript that the array is an integer array... with somethin like</p>

<pre><code>teamArray[team1] = 0;
teamArray[team1] = teamArray[team1] + 1;
</code></pre>

<p>but the problem is every time when i come to one of my functions, i have to set my array element to 0 and that makes the whole calculation wrong...</p>

<p>Could anyone give me a hint please?</p>

<p>My Idea was to was to set each array element to 0 from the beginning, but i dont know at the beginning of my game how many teams i will have today, that why i implemented the array like:</p>

<pre><code>var teamArray = [];
</code></pre>