2 dimensional array sum in javascript
<p>I need to add recurrently a 2 dimensional array. The ideea is that I have a generated 2 dimensional array and I have to get the sum of all the generated arrays.
I tried writing:</p>

<pre><code>sum+=parseFloat(twoArray[a][b]); 
</code></pre>

<p>however the script is blocked and I do not get anything. it is a loop so the values of <code>a</code>, <code>b</code> float from <code>0</code> to a variable inserted by the user. I have tested the script and this is the line where it breaks.</p>

<pre><code>if (k&gt;=3){                          
    for(var i=0;i&lt;A.length;i++){
        var smaller=new Array(A.length-1);
        for(var h=0;h&lt;smaller.length;h++){
            smaller[h]=new Array(smaller.length);
        }
        for(var a=1;a&lt;A.length;a++){
            for(var b=0;b&lt;A.length;b++){
                if(b&lt;i){
                    smaller[a-1][b]=A[a][b];
                }
                else if(b&gt;i){
                    smaller[a-1][b-1]=A[a][b];
                }
            }   
        }
        sum+=parseFloat(smaller[a][b]);
        alert (sum);
        //dam valorile
    }
}
}
</code></pre>
