Having a hard time googling for this since I'm not sure what the concepts are called, and all of the "combinations of two arrays/groups" SO posts are not giving me the output I would expect.
Example arrays:
var array1 = ['Bob', 'Tina'];
var array2 = [0, 100];
I can find possible combinations with nested looping through both arrays. But that would give me an output like:
var array1 = ['Bob', 'Tina'];
var array2 = [0, 100];
var options = []
array1.forEach(function (name) {
array2.forEach(function (number) {
options.push([name, number])
})
})
console.log(options);
> [ [ 'Bob', 0 ], [ 'Bob', 100 ], [ 'Tina', 0 ], [ 'Tina', 100 ] ]
this post (Creating Combinations in JavaScript) gives me the output above
But what I'm really looking for would give me arrangements/combinations like this:
[
[['Bob', 0], ['Tina', 0]],
[['Bob', 0], ['Tina', 100]],
[['Bob', 100], ['Tina', 0]],
[['Bob', 100], ['Tina', 100]]
]
And it would need to be able to scale with longer arrays, but 2x2 is the easiest example.
This cartesian example here (Matrix combinations of two arrays in javascript) also gave me broken out strings and not correlated arrangements:
[ { '0': 'B', '1': 'o', '2': 'b' },
{ '0': 'B', '1': 'o', '2': 'b' },
{ '0': 'T', '1': 'i', '2': 'n', '3': 'a' },
{ '0': 'T', '1': 'i', '2': 'n', '3': 'a' } ]
I have been looking through google and SO but I'm hitting roadblocks because I'm not sure what I'm actually looking for.