Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
- Preparing to Build the Classes 0:34
- Practice Brainstorming Properties
- Player Properties Solution 2:57
- Token Properties Brainstorming
- Token Properties Solution 2:33
- Build the createTokens() Method
- createTokens() Method Solution 3:06
- Board and Space Class Constructor Methods
- Board and Space Class Constructor Methods Solution 3:58
- Build the createSpaces() Method
- createSpaces() Method Solution 2:46
- Game Class Constructor Method
- Game Class Constructor Method Solution 2:45
- Reviewing Constructor Methods and Generating Objects 5 questions
Well done!
You have completed Object-Oriented JavaScript: Challenge!

- 2x 2x
- 1.75x 1.75x
- 1.5x 1.5x
- 1.25x 1.25x
- 1.1x 1.1x
- 1x 1x
- 0.75x 0.75x
- 0.5x 0.5x
See the solution for the createTokens() method assignment.
JS Documentation
To read more about how to document your JS code, visit usejsdoc.org and devdocs.io/jsdoc.
Code Documentation Correction
The project files are correct, but there's a small error in what you see on screen.
The documentation for this method is missing the @param information. The complete documentation should look like this:
/**
* Creates token objects for player
* @param {integer} num - Number of token objects to be created
* @return {array} tokens - an array of new token objects
*/
Solution Code
Player class constructor
method:
constructor(name, id, color, active = false) {
this.name = name;
this.id = id;
this.color = color;
this.active = active;
this.tokens = this.createTokens(21);
}
Player class createTokens()
method:
/**
* Creates token objects for player
* @param {integer} num - Number of token objects to be created
* @return {array} tokens - an arary of new token objects
*/
createTokens(num) {
const tokens = [];
for (let i = 0; i < num; i++) {
let token = new Token(i, this);
tokens.push(token);
}
return tokens;
}
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up