Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

find all subsets of an array javascript

const getAllSubsets = 
      theArray => theArray.reduce(
        (subsets, value) => subsets.concat(
         subsets.map(set => [value,...set])
        ),
        [[]]
      );

console.log(getAllSubsets([1,2,3]));
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #find #subsets #array #javascript
ADD COMMENT
Topic
Name
8+3 =