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 trialJoseph Anson
14,448 PointsWould this for loop work fopr the drawHTMLBoard() ?
I am so confused. I realised my original for loop wouldn't work and without copying the code in the video I wanted to try it myself first.
Would the following code work?
drawHTMLboard() {
for (let i=0; i < spaces.length; i++) {
for (let s=0; s < spaces[i].length; i++) {
spaces[i][s].drawSVGSpace();
}
}
}
Thank you
3 Answers
Steven Parker
231,269 PointsIt looks like you have a sound idea, but why not try it out and see for yourself? Testing it in place might help reveal any issues that need to be addressed.
Seth Kroger
56,413 PointsYour inner loop should have s++ instead of i++. Otherwise it should work.
Joseph Anson
14,448 PointsOops! Thank you
Dzmitry Aliakseichyk
12,290 Pointsfor (let i = 0; i < this.spaces.length; i++) { for (let x = 0; i < this.spaces[i].length; x++) { this.spaces[i][x].drawSVGSpace(); } } }
I suspect you also have to put 'this.' when referencing "spaces".