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 up-
Billy Jones
28,560 Points1 Answer
-
Kylie Soderblom
3,890 Points0 Answers
-
Patrick Eaton
3,860 PointsHow does JavaScript know what Token represents in this scenario?
Posted by Patrick EatonPatrick Eaton
3,860 Points1 Answer
-
Daniel Cranney
11,609 Points3 Answers
-
Manoj Gurung
5,318 Points1 Answer
-
Steve Fau
5,622 Points1 Answer
-
James Croxford
12,723 Points0 Answers
-
Brendan Moran
14,052 Points0 Answers
-
Murilo de Melo
14,456 Points1 Answer
-
Tetsuya Yokoyama
11,286 Points1 Answer
-
praveen
11,314 Points1 Answer
-
mk37
10,271 Points2 Answers
-
Michael Cook
Full Stack JavaScript Techdegree Graduate 28,975 Points1 Answer
-
fairest
Full Stack JavaScript Techdegree Graduate 19,303 Points1 Answer
-
YONGJIN KIM
Full Stack JavaScript Techdegree Graduate 20,287 Points3 Answers
-
William Daugherty
Full Stack JavaScript Techdegree Graduate 30,935 PointsNew link for JS Documentation writing?
1 Answer
View all discussions for this video
Related 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