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 Board and Space class constructor methods.
Template Literals
Template literals are an easier way to create a string that has embedded expressions, like a variable, for example.
Previously, you'd have to concatenate a string to a variable like this:
const name = "Ashley"
const newString = "Hello my name is " + name;
With template literals, you can do the same in an easier fashion. Template literals are enclosed in backticks instead of single or double quotes like a regular string. The embedded expression is wrapped in curly braces, and preceded with a dollar sign, right inside the string.
const name = "Ashley"
const newString = `Hello my name is ${name}`;
Solution Code
Board Class Constructor Method
constructor() {
this.rows = 6;
this.columns = 7;
this.spaces = [];
}
Space Class Constructor Method
constructor(x, y) {
this.x = x;
this.y = y;
this.id = `space-${x}-${y}`;
this.token = null;
}
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up-
PLUS
Jonathan Ambriz
Courses Plus Student 3,902 Points1 Answer
-
Ashish S
Python Web Development Techdegree Student 938 Points3 Answers
-
Ashish S
Python Web Development Techdegree Student 938 Points3 Answers
-
Adam Kubriczky
4,405 Points1 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