Without popping, the path keeps growing and the counts are wrong.
Acceptance criteria
- 1.#out should show eight subsets.
Without popping, the path keeps growing and the counts are wrong.
const items = [1, 2, 3]; const results = []; const path = []; function go(start) { results.push([...path]); for (let i = start; i < items.length; i++) { path.push(items[i]); go(i + 1); } } go(0); document.querySelector('#out').textContent = results.length === 8 && path.length === 0 ? "eight subsets" : "path left with " + path.length;
Output ready when you are
Press Run to render your code, or Submit to validate your solution.