I am trying to write a function that will take an array and n as parameters,
it will return all subsets of that array with n elements, have tried a couple things, couldn't yet succeed.
thanks to whoever put it here, this functions is way too complicated and doesn't do the job, basically what I tried to do here is to pick out one element from a 4 element array to create its 3 element subsets. It doesn't even take N as parameter. it returns all 3 element subsets but also identical ones, so I have to filter them out as well, in any case I will keep trying.
function findSubsets(array) { 
    var answers = []; 
    var firstArray = array; 
    for (i = 0; i < array.length; i++) { 
       array = firstArray; 
       for (var k = 0; k < array.length; k++) { 
          if (k != i) { 
              var subset = array.splice(k, 1); 
              answers.push(array); array.splice(k, 0, subset[0]);
          } 
       }
    } 
}
 
     
    