This particular function receives two arrays as input: arrOne, which is an array comprising arrays of numbers, and arrTwo, which is an array containing numbers. My goal here is to generate every possible combination, followed by obtaining the unique combinations. However, I've encountered a stumbling block.
function multOrdProduct(arrOne,arrTwo){
let backSet = [];
let count = 0;
let tempArr = new Array(arrOne.length);
let permArrOne = [];
let permArrTwo = [];
let pushed;
let setPart = [];
for(i=0; i < arrOne.length; i++){
permArrOne.push(arrOne[i]);
}
// ^sets permArrOne to equal the same array as ArrOne
for(i = 0; i < arrOne.length;i++){
for(j = 0; j < arrTwo.length; j++){
setPart = permArrOne[i];
console.log(permArrOne[i]);
setPart.push(arrTwo[j]);
backSet.push(setPart);
}
}
return backSet;
}
I initially believed that permArrOne[i]
would remain unchanged since no value assignment is made to it. Can anyone explain why it changes in each iteration?