jquery multitype Jagged array behaving strangely
Please refer to this:
http://jsfiddle.net/MasterOfKitties/v7xbu/7/
/*This is the desired behavior*/
/*var A = [1, 2, 3]*/
/*var B = "hello", [1, 2, 3],
"hello", [2, 3, 2],
"hello", [1, 5, 1]]*/
var A = new Array();
var B = new Array();
function fnMakeArray()
{
var strTemp;
var arrTemp = new Array();
strTemp = parseInt(window.prompt("Enter a number until you hit
cancel",""));
while (strTemp>0)
{
arrTemp.push(strTemp);
strTemp = parseInt(window.prompt("Enter a number until you hit
cancel",""));
}
A[0] = "hello";
A[1] = arrTemp;
alert(A);
}
function fnReplicateArray()
{
B.push(A);
fnDisBArray();
alert(B);
}
function fnDisBArray()
{
var strTemp;
for(var x = 0; x<B.length;x++)
{
strTemp += "<P>" + B[x] + "</p>"
}
document.getElementById('parse').innerHTML = strTemp ;
}
For some reason, when attempting to display the B array, it puts out
undefined. Furthermore, it does not seem to increment the jagged array
correctly, as the b[0] element begins to radically change even though the
b[1] or b[2] element is being arranged.
Any assistance? What's going on?
No comments:
Post a Comment