find all subsets of an array javascript

Solutions on MaxInterview for find all subsets of an array javascript by the best coders in the world

showing results for - "find all subsets of an array javascript"
Joana
09 Aug 2020
1const getAllSubsets = 
2      theArray => theArray.reduce(
3        (subsets, value) => subsets.concat(
4         subsets.map(set => [value,...set])
5        ),
6        [[]]
7      );
8
9console.log(getAllSubsets([1,2,3]));