javascript for sub set

Solutions on MaxInterview for javascript for sub set by the best coders in the world

showing results for - "javascript for sub set"
Jadon
16 Nov 2019
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]));
Paolo
19 Jul 2020
1[1, 2, 3]
2
Maya
09 Sep 2018
1[], [1], [2], [1, 2], [2, 3], [1, 3], [1, 2, 3]
2