I have 2 functions, in the first one I generate a bidimensional array and in the second one I define an array minus the last line and column. However it does not work. The code is as follows:
function calcDet () {
var A = []; //generates the array
for (var i = 0; i < k; i++) {
A[i] = [];
for (var j = 0; j < k; j++) {
var id = "A" + (i + 1) + (j + 1);
A[i][j] = parseFloat(document.getElementById(id).value);
}
}
return (A);
}
function returnDet() {
var s;
var A = calcDet();
var smaller=[];
for (var i=0;i<k-1;i++) {
smaller[i]=A[i]
for (var j=0;j<k-1;j++) {
smaller[i][j]=A[i][j];
}
}
alert (smaller);
}
Your code has undefined variables:
“k” seems to appear out of nowhere in both functions
Line
var id = “A” + (i + 1) + (j + 1);
will generate identical id for (some) different variations of i and j ([i = 11 and j = 1] == [i = 1 and j = 11]) that may be a cause of further errors
And it is always useful if you mention the error that you are getting – I would expect that your scripts would not run at all as they are…