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

typeError in object oriented javascript challenge course

this is the error am receiving Uncaught TypeError: Cannot read property 'filter' of undefined at Player.get unusedTokens [as unusedTokens] (Player.js:18) at Player.get activeToken [as activeToken] (Player.js:21) at Game.startGame (Game.js:14) at HTMLButtonElement.<anonymous> (app.js:4) below is my workspace https://w.trhou.se/1nnuf9zf79

2 Answers

Hi. I took a look at your code and in the Player class this is your function:

constructor(name,id,color,active= false) {
    //other properties
    this.token=this.createTokens(21);
}
get unusedTokens(){
    return this.tokens.filter(token => !token.dropped);
}

I think the problem is that you have a token property, but you're trying to filter using this.tokens. You probably need to change your property to this: this.tokens=this.createTokens(21);

help identify the problem in this also Board.js:22 Uncaught TypeError: space.drawSVGSpace is not a function at Board.drawHTMLBoard (Board.js:22) at Game.startGame (Game.js:13) at HTMLButtonElement.<anonymous> (app.js:4) https://w.trhou.se/to5ewuxgng