Cube Matcher Step 12 & 13

This is the project

I’m not sure what’s going on here, I do what it tells me to but when I click on cubes nothing happens.

Here are the steps:

Remove the matching cubes from the board. Find the conditional that checks neighborCubes.length > 0 below the line where you declared neighborCubes . We’ve given you the code that updates the score, but the code to update the board by removing matching cubes needs to be added. Under the code for the score, use an iterator on neighborCubes to visit each neighboring cube and for each cube run some code. Pass in a callback function to the iterator with neighbor as the only parameter.

Once you’ve done that, add this code to the callback function’s body:

// Remove neighboring cube from displayneighbor.destroy();

This Phaser code will remove the neighbor cube from the display.

The last step of this section is to move the remaining cubes down after their neighbor is removed from the board:

// Shift remaining cubes downrenderCubes(neighbor);

Check your work by restarting the game and clicking on cubes. Any cube that has at least one other matching cube connected to it should now disappear and any cubes above them should move down the board.

my code:

if (neighborCubes.length > 0) {

        // Update score

        score += neighborCubes.length;

        scoreText.setText(`Score: ${score}`);

        // Update each cube in neighborCubes here

        neighborCubes.forEach(neighbor => {






Can someone help me?

The snippet of code you posted looks fine, so the error must be occurring somewhere else.

Have you checked the browser’s console to see if there are any clues?

1 Like

I don’t see any errors but I’m not 100% sure I’m looking at the right thing. I clicked on inspect element, then I clicked on console. Then I ran the code and there are no errors, but there are 5 warnings.
I’m not sure that I’m looking at the right thing though.

It sounds like you’re looking at the right thing if you clicked Console

I copy/pasted your snippet into my completed project and it still worked fine:


1 Like

Removing extra columns doesn’t begin until Step 14 so I’m not sure what behavior you’re supposed to see yet, but I can tell you that your block of code is fine

1 Like

I’m going to try to run all the code locally and see what comes up

Thanks for your help by the way

I’m not sure what to do this isn’t working.
my get neighbor function seems to be okay:

const getNeighbors = (cube) => {

  // Variables

  let start = cube;

  let cubesToCheck = [start];

  let validNeighborCubes = [];

  // Check cubes in cubesToCheck for valid neighborCubes

  while (cubesToCheck.length > 0) {

    let curr = cubesToCheck.shift();

    // Only collect cubes we haven't already removed as a valid neighbor

    if (curr.removed === false) {


      curr.removed = true;


    // Add code to get matching cubes, below

    const matches = checkClosest(curr);

    matches.forEach(match => {

      match.removed = true;





Is that the full function?

1 Like

Yes. Is that wrong did I forget something.

You didn’t include the return line when you copy/pasted. It isn’t in the screenshot either, but I assume you have one or there would likely be other errors. Maybe it would be good to share the whole thing with the link from this so we can look it over holistically:

1 Like

Here’s what I see in the console when I start the game and click a cube:


1 Like

Ohhhhhh :joy: I forgot to click a on a cube when I got to the console. I just hit run. I feel really dumb! I get the same thing

These things happen!

So do you want to take a crack at debugging this?

1 Like

When I define: const neighborCubes = getNeighbors(); I don’t include a parameter.

1 Like

Thanks for all your help!

1 Like

You got it! Nice find

1 Like