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 Object-Oriented JavaScript: Challenge Building Constructor Methods and Generating Objects createSpaces() Method Solution

Tyler McDonald
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Tyler McDonald
Full Stack JavaScript Techdegree Graduate 16,700 Points

Possible Error in the HTML Scripts?

Hi, please correct me if I'm wrong or misunderstanding, but I think I came across an error in the way the js files are loaded into the HTML with the scripts (i.e. <script src = "js/Board.js"></script>).

Whenever creating the Board class, and subsequently calling the Space class in order to create spaces for the board, I kept getting an error in the console Uncaught ReferenceError: Space is not defined.

After trying a series of fixes, I finally found one that worked. I went to the HTML file, move the <script src="js/Space.js"></script> before <script src = "js/Board.js"></script> and it finally worked!

Is this an error in the way the program files were set up, or is there a different/better solution than what I did? It seems really odd that the JS files would have to be structed in a specific way, but I could not find a better solution. Thank you!

Steven Parker
Steven Parker
231,269 Points

The order sensitivity may be a result of something in your code. If you'd like help finding it, make a snapshot of your workspace and post the link to it here.