working on a practice problem. The problem asks write a method ‘combinations’ that takes in an array of unique elements and returns a 2D array representing all possible combinations of 2 elements in of the array
Here is the expected output:
combinations([“a”,”b”,”c”]) => [[“a”,”b”], [“a”,”c”], [“b”,”c”]]
combinations ([0, 1, 2, 3]) => [[0,1], [0,2], [0,3], [1,2], [1,3], [2,3]]
Here is my code and output:
confused on why its saying array[2] for every-one. What am I missing?