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 trial

JavaScript Object-Oriented JavaScript: Challenge Rendering the Game startGame() Method Solution

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,253 Points

[SOLVED] Help! "TypeError: this.activePlayer.activeToken.drawHTMLToken is not a function"

Hi all,

Okay, so I answered my earlier thread about why the earlier render methods weren't showing up on the screen. "Duh, I hadn't yet called them" ;)

this.activePlayer.activeToken.drawHTMLToken

How I have a different problem. I'm going to investigate this more as much as I can but I thought it might help to open this problem up to the community. Basically, the tokens are not working properly when I click the "start" button... with the following error.

Uncaught TypeError: this.activePlayer.activeToken.drawHTMLToken is not a function
    at Game.startGame (Game.js:39)
    at HTMLButtonElement.<anonymous> (app.js:13)

I've through the stack trace as much as I can but I can't find the issue.

Solved - I was passing in the wrong variable to the push() function in createTokens();

I won't post the complete method but the key takeaway is to make sure you're passing in the right variable so that the method is successfully returning something.

Heidi Vasterling-Ford
Heidi Vasterling-Ford
7,806 Points

I am receiving the exact same 2 errors as you were. In the createTokens(); function I am pushing (token). Seems weird as:

this.token = null;

I am pretty lost here.

1 Answer

Maya Husic
Maya Husic
13,488 Points

Thanks for the hint! :)