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 trialKylie Soderblom
3,890 PointsNote: Corrected version of Token constructor see here. Question about When creating a new Token obj. (i, this),
First off there is a correction to the code: See Token.js, constructor and add params:
constructor(index, owner) {
My question, when creating a new Token obj in Player.js
let token = new Token(i, this);
Why not be more specific and say (i, this.id) ?
Daoud Merchant
5,135 PointsDaoud Merchant
5,135 PointsThe reason the whole
owner
object has to be passed as a parameter is because theToken
class constructor stores a reference to that whole object, not just the id:If
Token
didn't store anowner
parameter, indeed, you could write:And call it with
new Token(i, this.id)
.Hope this helps!