Lets say I have several sets of options in Javascript
var color = ["red", "blue", "green","yellow"];
var size = ["small", "medium", "large"];
var weight = ["heavy", "light"];
what is an efficient algorithm to get all the combinations of these options in an array that looks like this
["red and small and heavy", "red and small and light", "red and medium and heavy" ...]
Here's the caveat though
This function must be able to take any number of sets of options
I have a feeling that the proper way to do this is through some sort of tree traversal, but its too early to have fully thought this through and I haven't had my coffee yet