Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript Object-Oriented JavaScript: Challenge Making the Game Interactive playToken() Method Solution

1 Answer

I realized it's been awhile since the question was asked, but for anyone else:

They don't all become the target space. As the for loop iterates through the column, it sets targetSpace to the current space in the iteration. In other words, since the targetSpace variable is declared with 'let', each time the for loop runs it replaces the variable with the new iteration. Furthermore, it only replaces the declaration if the space is not null. That means that when the loop is finished, the last space in the column (the bottom space) that is not null will be the value of the the targetSpace variable.