Multidimensionnal array in Javascript
<p>I'm trying to build an array of strings, but I got an </p>

<pre><code>Uncaught TypeError: Cannot set property '0' of undefined 
</code></pre>

<p>I don't really get why, here is my code.</p>

<pre><code>$("#tableLits &gt; tbody &gt; tr input").filter(function(){ return $(this).val() !== '' }).each(function(){
    nom = $(this).attr('name');
    numChambre = parseInt(nom.charAt(nom.length-1));
    taille = nom.slice(nom.charAt(nom.length-2),-2).replace('lit','');          
    chambres[numChambre][nbLits] = taille;              
    nbLits = oldChambre == numChambre ? nbLits++ : 0;
    oldChambre = numChambre;

});
console.log(chambres);
</code></pre>

<p>The error is on this line : </p>

<pre><code>chambres[numChambre][nbLits] = taille;  
</code></pre>

<p>But when I look at the debugger,</p>

<ul>
<li>Chambre is an array</li>
<li>numChambre = 1</li>
<li>nbLit = 0</li>
</ul>

<p>My goal is to assign a size of a bed (taille) to a bed number (nbLit) in a given room (chambres)</p>

<p>If you have an idea,</p>

<p>Kai23</p>

<h2>Edit</h2>

<p>For exemple, I have this :
lit80n1
lit90n1 
lit120n2
lit160n3</p>

<p>And I want to output something like this :</p>

<pre><code>Chambre 1 -&gt; 1 bed : 80cm, 1 bed : 90cm
Chambre 2 -&gt; 1 bed : 120 cm
Chambre 3 -&gt; 1 bed : 160cm
</code></pre>
