Apologies, I am a newbie and I'm having trouble wording my question enough so I can search for it here, I tried but I couldn't find the answer using my search terms.
Given 1. a number length of array and 2. an array of different numbers how can I have combination like this through recursion?
const number_of_combinations = 4; // the arrays must be 4 in length
const combinations = [1,2,3];
// answer
// [1,1,1,1]
// [1,1,1,2]
// [1,1,1,3]
// [1,1,2,1]
// [1,1,2,2]
// [1,1,2,3]
// etc....
p.s. If you can point me to a duplicate or answer I will delete this question right away, I know this must be something that's already been answered here.