Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

TYPEeRROR

help identify the problem in this also Board.js:22 Uncaught TypeError: space.drawSVGSpace is not a function at Board.drawHTMLBoard (Board.js:22) at Game.startGame (Game.js:13) at HTMLButtonElement.<anonymous> (app.js:4) https://w.trhou.se/to5ewuxgng

5 Answers

Steven Parker
Steven Parker
231,141 Points

On line 20 of "Board.js", it looks like you might have used "in" where you meant to use "of":

      for(let column in this.spaces){    // did you mean "of" instead?

help me to use for...loop instead of for..of ;

by for..loop i mean this for(let i=0; i<(the length of the array ); i++){

}

Steven Parker
Steven Parker
231,141 Points
      for (let i=0; i<this.spaces.length; i++) {
          let column = this.spaces[i];

you havent completed the question... include the looping through drawSVGSpace please.

Steven Parker
Steven Parker
231,141 Points

I wasn't intending to do a complete re-write. I was giving you an example of how you can translate a "for....of" into a traditional "for", and I thought you could handle translating the inner loop yourself with that model.

But since you asked, a similar translation of the inner loop might look like this:

    for (let s = 0; s < column.length; s++) {
      let space = column[s];

THANK YOU MAN

steve if you can help me find the bug in my code ... cant interact with the game man! below is my work space: https://w.trhou.se/v5x93iq5cr