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 Rendering the Game `Write Getter Methods for unusedTokens, activePlayer and activeToken

createPlayers() has error in Game.js (Connect Four Game)

Where is the link on how to markup code?

Here's the code in the meantime:

createPlayers(){
    const players = [new Player('Player 1', '#e15258', 1, true ),
                     new Player('Player 2', #e59a13, 2)];
    return players;
}

Here's the error:

-private fields cannot be accessed without an explicit 'this.' qualifier

1 Answer

Robert Manolis
STAFF
Robert Manolis
Treehouse Guest Teacher

Hi Jonathan, thanks for reaching out about this. I just downloaded the project files for this course, and the final version of the project files aren't showing any errors. So I think the issues is with how you are referencing the code in question, rather than the supplied code itself.

And for future reference, here's a friendly suggestion. The more info you can provide in your post, the more likely we are to be able to find the root of the problem and provide you with a helpful response. For example, sharing an actual link to the video or code challenge in question is a big help. Providing the full error message, including line numbers is helpful as well. And then linking either to your workspce, or codepen, or fiddle, or best of all, a GitHub repo of your code can make a world of difference.

Thanks Jonathan, and please have a great rest of your day! :)