Sorry I'm new to node js. If you look at the ListComp array it has changed after the while loop. Could someone explain what is wrong with this code?
function FormGrp() {
var ListOne = [];
var ListTwo = [];
var count = 0;
var Control;
var graph = [];
var ListComp = [[59],[73,41],[52,40,9],[26,53,6,34],[10,51,87,86,81]];
Control = 4;
console.log(ListComp);
while(Control != 0){
ListOne = ListComp[count];
ListTwo = ListComp[count+1];
for(var i=0; i<ListOne.length; i++){
for(var j=0; j<ListTwo.length; j++){
if(j === 2){
ListTwo.shift();
break;
}
graph.push([ListOne[i],ListTwo[j]]);
}
}
count++;
Control--;
}
console.log('\n',ListComp);
}
In the two console outputs the values were different, but I did not use any mocking method in the ListComp array, how could it have been changed?