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 Board and Space Class Constructor Methods Solution

OOP concepts?

Why always these constant numbers? We pass 21 as a number of player tokens, respective constant numbers for rows and columns.. Why not making it able to be played on an arbitrary sized board and calculate the numbers appropriately?

1 Answer

Camilo Lucero
Camilo Lucero
27,692 Points

I thought the same while taking that course. I believe that many parts of the game can be made better and more dynamic. However, the game may already be complex for most people beginning to learn Javascript, which is why I think they tried to keep it simple.

My approach was to refactor the game after watching the course. You can make things like selecting how many spaces the board will have, or keeping a score of wins and losses for each player.

Realizing that things can be done better is a great indicator that you are on the right way in your learning path.

Félix Guérin
Félix Guérin
17,910 Points

Exactly! This course so far is perfectly suited to my level, but like you I can already see a lot of ways to improve the game. I'll just finish the project then try to integrate these new features afterwards. This is really good practice.