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 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.