Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
- Connecting with the DOM
- Connecting with the DOM Solution 3:21
- Rendering Spaces
- Render the Board
- Render the Token
- Rendering the Spaces, Board, and Tokens Solution 5:11
- `Write Getter Methods for unusedTokens, activePlayer and activeToken
- Getter Methods Solution 2:44
- Build the startGame() Method
- startGame() Method Solution 2:53
- Reviewing Rendering the Game 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 rendering the Space, Board, and Token objects.
Jump to Solution Timestamps
1:40 - drawSVGSpace() solution
2:43 - drawHTMLBoard() solution
4:03 - drawHTMLToken() solution
Some Background on SVGs
SVG stands for Scalable Vector Graphics. MDN describes SVG as an XML-based markup language for describing two dimensional based vector graphics. It says “SVG is essentially to graphics what HTML is to text”. Essentially, SVG is a way to write, or describe, a graphic element in code. SVGs are great for displaying shapes on your website or app.
You might be wondering: why not just use CSS? Well, CSS can do a lot, for sure. But the reason SVGs are the right choice for this part of the app is because it offers the ability to clip and mask objects. On a real life “Four in a Row” board, the spaces that the tokens are dropped into are actually holes in the board. To recreate this “hole” effect in our game, we have to use SVGs masking capabilities.
For...of Loops
Check out the JavaScript Syntax Reference or the MDN documentation to learn more about for...of
loops.
Code Correction
Line 17 in the drawSVGSpace()
method in the Space.js file is unnecessary. Remember when I mentioned that apps often go through many iterations? Adding the data-column
attribute to the SVG element was important in a previous iteration, but not used in the final project. Feel free to ignore it. Its presence doesn't anything, but you won't see it utilized in the rest of the course.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up-
michael apprich
9,989 Points1 Answer
-
Konstantin Schwemlein
3,617 Points1 Answer
-
Chris Adams
Front End Web Development Techdegree Graduate 29,423 Points2 Answers
-
Steve Fau
5,622 Points1 Answer
-
Seth Lewis
Full Stack JavaScript Techdegree Graduate 18,191 Points1 Answer
-
PLUS
Jonathan Ambriz
Courses Plus Student 3,902 Points3 Answers
-
Joseph Anson
14,448 PointsWould this for loop work fopr the drawHTMLBoard() ?
Posted by Joseph AnsonJoseph Anson
14,448 Points3 Answers
-
YONGJIN KIM
Full Stack JavaScript Techdegree Graduate 20,287 Points1 Answer
-
Unsubscribed User
5,918 Points2 Answers
-
Yannis Bouacida
9,169 Points4 Answers
-
Domagoj Kirigin
16,392 Points2 Answers
-
MOD
Jonathan Grieve
Treehouse Moderator 91,254 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