I am trying to find all the combination of two arrays, but with an important variation:
Each value of the second array needs to be spread out over the val
Just for illustration, this is a version of @NinaScholz's
answer that doesn't use toString
for base conversion or
implement counting manually. I've kept the structure of the
code the same. values.length-i-1
could simply be `i', but
I wanted to keep the order of the output the same too.
var combine = function(names, values){
var result = [],
max = Math.pow(names.length, values.length),
m;
for(m=0; m