[Solved] Looping javascript multi array


Three loops for each array. Just loop through every array, and append to new array.

var size = ['s','m'];
var color = ['red','blue','black'];
var material = ['cotton','linen'];

var arrayMaterials = []

for (var i = 0; i < size.length; i++) {
  for (var j = 0; j < color.length; j++) {
    for (var k = 0; k < material.length; k++) {
      arrayMaterials.push(size[i] + "," + color[j] + "," + material[k]);
    }
  }
}

console.log(arrayMaterials);

0

solved Looping javascript multi array