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 trialjun cheng wong
17,021 PointsOrder of the arguments in the constructor parameter
class Token {
constructor (index, owner) {
this.owner = owner;
this.id = `token-${index}-${owner.id}`;
this.dropped = false;
}
I could not understand why the 'index' argument should be put as the first argument. When I put 'owner' as the first argument as below, the token will be missing.
class Token {
constructor (owner, index) {
this.owner = owner;
this.id = `token-${index}-${owner.id}`;
this.dropped = false;
}
1 Answer
Cory Harkins
16,500 PointsWhen you initialized the class passing in those arguments, where they in the order expected? Or is treehouse calling the class in a particular way that you don't have visibility of during testing?