Treasure Hunter

I tried going through the Treasure Hunter project, and it isn’t running properly. I can’t seem to find where I made a mistake in my code. Could you please help?
my code:

Hi thanks for sharing!

It’s not running properly how? If it’s throwing an error that’s very specific and sharing the error message can help.

If it’s something your code is not doing, setting up log statements up the control flow of what’s not working is also very useful.

Hello and thanks for your short reply! There’s no error message, but the program just isn’t working the way it’s intended. When I run the program, it shows the start screen, and when you click on the screen, it goes to the gameplay screen. So far, so good. However, once you try clicking on the plots, nothing happens. The score doesn’t register and nothing changes. Any ideas why?

Do you think this code snippet could be at fault? I tried to follow the instructions, but they were a little confusing.
The code:
// The background is provided below

  this.add.sprite(240, 320, 'board');    

  // Create the for loops to create the grid

  for (let x = 46; x < 437; x += 78) {

    for (let y = 46; y < 437; y += 78) {

     plot = this.add.sprite(x, y, 'blank'); 




Some other potential trouble spots:
function decideCoinLocations() {
while (coinCollection.length < 5) {
let randIdx = Math.floor(Math.random() * grid.length)
let selectedPlot = grid[randIdx]
if (coinCollection.indexOf(selectedPlot) === -1) {

function playerCheck() {
for (let i = 0; i < coinCollection.length; i++) {
if (clickedPlot === coinCollection[i]) {
playerCoins = playerCoins + 1;
} else {

I think you need to check the portion of the code with the click handlers then. To start with. Even if you need to simplify it or just try the code in isolation somewhere else (to make sure it works like you think it should)

@btheoriginal every bit of code that you doubt, try devising a mini-test in a test.js file to see if it works like you think it should. You might have to input some dummy data to get a full idea of whether it’s working like you want or not.

Whenever I write this much code and I have no clue where the error comes from, it really is a matter of “larger strategy” and just breaking it down to more manageable portions. The steps learned on the way will help get to be more in control when the code base is larger.