Using phaser, how do I make the bricks I created appear on screen?

Hi all

I am following this tutorial: Collision detection - Game development | MDN

I copy pasted their code into my repl. In their game, bricks appear, but in my game, they don’t. Why is this? What must I change?
Their game: Gamedev Phaser Workshop - lesson 10 - JSFiddle - Code Playground
My game: https://replit.com/@jaimeggb/2D-breakout-game-using-Phaser#public/index.js

Thanks for your time

Jaime

@lasjorg any thoughts on this? You solved my previous problem regarding getting a black canvas using phaser the other day, perhaps you know what may be wrong this time?

You need to declare the loop index variables in the two for loops inside initBricks.

Not sure why the original code is written that way, it’s never a good idea to have undeclared variables. If you look in the console you can see the error.

1 Like

Thanks again @lasjorg, you make it look easy :fist_right: :fist_left: