In this article, we will illustrate how we can use recursive generator functions to produce an iterator for array combinations. We will first see how to generate n-combinations, and then we will move on to generating all combinations.
Consider the following array:
const array = [1, 2, 3, 4, 5];
We are interested in writing an n-combination iterator function combinationN(), which should produce…