Cube matcher step 13, cant find what i did wrong

When i click on cubes nothing happens, probably did something wrong on the function before, but i cant see what.
EDIT: while looking through Opera console i noticed this error:
Uncaught ReferenceError: curr is not defined
at getNeighbors (GameScene.js:204)
at initialize. (GameScene.js:68)
at initialize.h.emit (phaser.min.js:1)
at initialize.processDownEvents (phaser.min.js:1)
at initialize.update (phaser.min.js:1)
at initialize.updateInputPlugins (phaser.min.js:1)
at initialize.queueMouseDown (phaser.min.js:1)
at onMouseDown (phaser.min.js:1)
EDIT 2 : after trying to reload the page the error changed into:
Uncaught ReferenceError: renderCubes is not defined.

const neighborCubes = getNeighbors();

  // Remove matching cubes from game if there's at least 2 of them

  if (neighborCubes.length > 0) {

    // Update score

    score += neighborCubes.length;

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

    // Update each cube in neighborCubes here

neighborCubes.forEach(neighbor => {





  // Helper function moves cube sprites down

  function renderCubes(cube) {

    for (let row = 0; row < cube.row; row++) {

      // Move cube sprite down by 30px

      board[cube.col][row].y += cubeSize;

      // Update the row of cube

      board[cube.col][row].row += 1;


    // Update board array

    let removed = board[cube.col].splice(cube.row, 1);

    board[cube.col] = removed.concat(board[cube.col]);



// Shift remaining cubes down



Hi @ajax1350787806
I don’t have PRO so I can’t see the exercise. I also cannot see what your function getNeighbors does, because you didn’t post it here. But I see the function call on the first line of code and that you don’t pass any arguments there. Where does the function get curr from?

The function getNeighbors is provided by the exercise, here is the step:
Inside of the event handler and after the line you located (wich is the one above that You cant see it in the post) in the previous step, create a constant variable neighborCubes and store the result of calling getNeighbors() with the clicked cube.
And as stated in Edit 2, the error changed to:
Uncaught ReferenceError: renderCubes is not defined
at GameScene.create (GameScene.js:96)
at initialize.create (phaser.min.js:1)
at initialize.loadComplete (phaser.min.js:1)
at initialize.h.emit (phaser.min.js:1)
at initialize.loadComplete (phaser.min.js:1)
at initialize.fileProcessComplete (phaser.min.js:1)
at t.onProcessComplete (phaser.min.js:1)
at (phaser.min.js:1);
The line in GameScene.js:96 is : renderCubes(neighbor); (which was also provided by the exercise)
Sorry for broken English not my main language

Can you post the provided function getNeighbors()? I assume that it expects an argument.

I mean if i try to search it through the console with getNeighbors().search(); it says getNeighbors is not defined
at :1:1.
Is there any other way to look for it?

Doesn’t the exercise provide folders with functions that you import in your current workfile?
If you console.log(getNeighbors()), what does it say?

VM6006:1 Uncaught ReferenceError: getNeighbors is not defined
at :1:9

Then there is no such function. Sure you’re not supposed to have written it yourself?

Yeah pretty sure let’s say 99%, i’ve read every step a bunch of times now to check if i was supposed to write it, but is never said, i could copy paste all the steps if You want to give it a read yourself

Before you start writing code of your own, browse the various files of the project to view them in the text editor. Take a moment to look over the structure of the project, in particular, the file GameScene.js . To complete Cube Matcher, you’ll only have to use this file.

There are comments in all the files including GameScene.js to help you understand what the code is doing if you’re interested, however, it’s not necessary to be familiar or know anything specific about the existing code to successfully finish this project. For now, take a moment to look over the comments and code; why do you think this might be more helpful rather than putting all the code in one file?

To finish this step, return to GameScene.js . Familiarize yourself with the general shape of the file, as you will be adding code throughout.

Display the Board

Start by opening the Cube Matcher game in your browser and clicking on the start screen. You should see the game screen with a score displayed and a timer counting down, but with an empty grid with no actual cubes.

Scroll down the GameScene.js file until you find the method called .makeBoard() below the .update() function. .makeBoard() contains all the code needed to create a 12 by 12 board of colored cubes and display them in the browser – exactly what we need. However, .makeBoard() is missing some code.

Find the variable called board in .makeBoard() . This is a nested array that represents a grid of cubes, with each inner array representing a column of cubes. For example, a 2 x 2 grid would be:

[  ['x', 'x'], // column 0  ['x', 'x']  // column 2]

Stuck? Get a hint

In this step, you’ll fill the empty spaces in the columns of the game with cubes.

Because board is a nested array, we need to iterate at each level of nesting to replace the empty spaces of the board with cubes: first, over each column, and then over each empty space in that column.

We’ve already given you code that maps over the columns of the board,, i) => {}) . However, in order to reach the cubes in each column, we also need to iterate over each cube in the given column, col .

Inside of the body of the callback function given to you in makeBoard() , use .map() , to iterate over each column, col . The callback function in the nested iterator should have 2 parameters: row and j for a cube in the column and j , the index of that cube in the column.

Stuck? Get a hint

Inside the inner .map() , call the helper function this.makeCube() and pass in i and j . Return this value.

Stuck? Get a hint

Save your code and restart the game. Make sure you now see a board filled with colored cubes displayed.

Collect all Matching Neighbor Cubes

Take a look at the board of the game in your browser. Find different groups of connected cubes of the same color; are they all the same number and shape?

In Cube Matcher, groups of cubes will have different numbers of cubes and shapes, generated at random. We’ve provided a function, checkClosest() , that checks the 4 cubes to the left, right, top, and bottom of a selected cube. How can we check larger groups of cubes with irregular shapes?

The code in the getNeighbors() function will do that for us. Scroll down GameScene.js and find getNeighbors() underneath the code for checkClosest() . This function finds all the cubes of the same color that are connected to each other, including the cube the player clicked on.

Below the conditional in getNeighbors() , create a constant variable, matches , and assign it checkClosest(curr) . checkClosest() returns an array of cubes of the same color connected to the cube passed into it.

Iterate over each of the matching cubes in the array stored in matches using the .forEach() iterator. The callback passed to the iterator should have a single parameter named match to represent the current matching cube.

Finally, add the following code to the callback’s body to complete getNeighbors() :

match.removed = true;validNeighborCubes.push(match);cubesToCheck.push(match);

This code marks each matching cube as no longer playable and collects it in an array with any other matching cubes.

Update the Board

The game is still not playable since we aren’t actually using getNeighbors() yet. In the next steps, we’ll fix this by adding code to the function that runs when a player clicks on a cube.

In GameScene.js , scroll up to find the following line inside the .create() method and after the function onTimedEvent() :

this.input.on('gameobjectdown', function(pointer, cube, event) {

This callback function (called an event handler ) will be called whenever a cube is clicked. You will complete this callback in the following steps.

Inside of the event handler and after the line you located in the previous step, create a constant variable neighborCubes and store the result of calling getNeighbors() with the clicked cube.


The clicked cube is passed into the event handler as the second argument, cube .

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.

so sorry that i wasted your time sorry man :frowning:

Don’t worry. Happy coding then.