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 Getter Methods Solution

I am not sure my code is correct

this is the best code I could come up with the video didn't help much with the firt part of this code https://teamtreehouse.com/library/getter-methods-solution

class Player { constructor(name, id, color, active = false){ this.name = name; this.id = id; this.color = color; this.active = active; this.tokens = this.createTokens(21); /* return value from the method call */ } }

/**

Creates token objects for player @param [integer] num - Number of token objects to be created / createTokens(num); { const tokens = []; / empty array */

 for (i = 0; i < num; i++) { let token = new Token(i, this);/* new variable token = to new token
 object, loop index and owning player passed here / tokens.push(token); / newly created token 
added to the tokens array */ }
return tokens; 
get unusedTokens ()
{ return this.tokens.filter(token => !token.dropped);
}

get activeToken() 
{ return this.unusedTokens[0]; 
}

get activeToken() 
{ return this.tokens.find(token => !token.dropped); 
}

Hey James, why won't you ease it up for everyone and format your code. Believe me it helps alot when you can read your own code clearly.