Cube Matcher, chaining iterators

I’m currently doing the Cube Matcher project:

For steps 14 through 20 we are told to make a function that will use the .map iterator to check through a number of arrays with the .every iterator to see if they are empty, then chain a .filter iterator to return index values of arrays that return truthy.

I am confused, as soon as I click on the game, all but the leftmost column disappear:

// Declare a emptyCols here:
  const emptyCols =, i) => 
    const isEmpty = col.every(cube => cube.removed);
    isEmpty ? i : false;
  }).filter(index => index !== false)

With all due respect to the people who made these projects, but when most the code is already there, it’s hard to really grasp what you are really coding with these steps, as it is often variables and such that are used by other pre-defined functions, so when you do something wrong it’s really hard to understand why and what is happening. It feels more like just mindlessly following the steps and hoping it works, without even really knowing what you are doing.

If I try printing emptyCols, after clicking something in the game, this is what I get:
(12) [undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined]

Nevermind, just solved it, was missing a return isEmpty at the end of the .map function.

I was under the impression the ternary operator was already returning the values.

With all that said, My game is still behaving pretty wonky, sometimes and I don’t know why. Sometimes I click and different color cubes disappear, and often times when there is a several empty column gap, the rightmost columns only go a few columns to the left per click instead of immediately joining the leftmost ones. Also towards the end of the game when there is only columns on the left, the game starts behaving oddly and letting me remove even cubes that are not touching any of the same color. I have gone over the steps about 3 times already and I can’t identify any errors, especially as the steps preceding the iterator chaining are pretty specific.

Edit: turns out it was the ternary’s fault. It only returns true or false and I thought it was returning actual index. Fixed that with an if statement to return the expected values.