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 trialRichard Preske
Courses Plus Student 4,356 PointscheckForWin() not a function in Game.js line 80 and token only drops one space one player only
Token only drops one space left right moves OK. checkForWin is not a function error after dropping a token. Thanks for any help.
1 Answer
Steven Parker
231,248 PointsThe message is accurate, there is no "checkForWin" function in Game.js.
But there seems to be one in Space.js, was it added to the wrong file?
Richard Preske
Courses Plus Student 4,356 PointsRichard Preske
Courses Plus Student 4,356 PointscheckForWin() is function in Space.js and checkForWin is called in Game.js line 80. The devtools are saying in updateGameState the function checkForWin is not a function.
Steven Parker
231,248 PointsSteven Parker
231,248 PointsBut the code in Game.js calls this.checkForWin(). The "this" means "in this same class", which means "Game" and it's not there!
Richard Preske
Courses Plus Student 4,356 PointsRichard Preske
Courses Plus Student 4,356 PointsThanks, should be in Game.js checkForWin that is. But not sure why my token doesn't fall to bottom open space. It only drops one space. Also getting maximum call stack exceeded in space.js get owner method.
Steven Parker
231,248 PointsSteven Parker
231,248 PointsIn Game.js on line 79, "mark" is being passed the target instead of the token. See if you can continue the debugging from there (hint: "player" is not an array).
If your original question has been answered, any additional issues should get a fresh question.