How can we transform an array of objects with nested arrays into a new array of objects with mixed values?
Consider the following input:
var all = [
{
name: "size",
value: [20, 10, 5],
},
{
name: "color",
value: ["red", "black"],
},
{
name: "width",
value: [500, 600],
},
];
The desired output should be like this:
var output = [
{ size: 20, color: "red", width: 500 },
{ size: 20, color: "red", width: 600 },
{ size: 20, color: "black", width: 500 },
{ size: 20, color: "black", width: 600 },
{ size: 10, color: "red", width: 500 },
{ size: 10, color: "red", width: 600 },
{ size: 10, color: "black", width: 500 },
{ size: 10, color: "black", width: 600 },
{ size: 5, color: "red", width: 500 },
{ size: 5, color: "red", width: 600 },
{ size: 5, color: "black", width: 500 },
{ size: 5, color: "black", width: 600 },
];