I have 4-5 arrays, and I need to combine them in every possible order.
for example:
var Arr1: [R01,R02,R03,R04,R05]
var Arr2 : [A1,B2,C3,D4,E5]
var Arr3 : [ab,ac,ad,ae,af,ag,ah,ai,aj,ak]
var Arr4: [xyz,abc]
I need the positions to stay the same, so Arr1 is always in position 1, and Arr2 is always in Position 2.
I'd the like the output to look like this, cloning and updating a div each time:
R01,B2,ac,xyz
R03,D4,ag,xyz
at the moment, I'm using this, but It doesn't seem to work
var iteration = 0;
for (let a of Arr1) {
for (let b of Arr2) {
for (let c of Arr3) {
for (let d of Arr4) {
console.log(a, b, c, d);
iteration++;
var div = document.getElementById('comboContainer'),
clone = div.cloneNode(true);
clone.id = "comboContainer" + iteration;
Text1.textContent = a;
Text2.textContent = b;
Text3.textContent = c;
Text4.textContent = d;
}
document.body.appendChild(clone);
}
}
}
it only seems to clone the even numbers, and only up to 100. The divs seem to all have identical Arr4 with no variation.
edit: I have added an example: https://jsfiddle.net/sgpascoe/yr4uk8nz/5/
As you can see, every box is an odd number, and every 'Arr4' is returning 'xyz'. except box 500, which is the first number?