Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript Object-Oriented JavaScript: Challenge Making the Game Interactive playToken() Method Solution

.a{fill-rule:evenodd;}techdegree seal-36
Full Stack JavaScript Techdegree Graduate 20,287 Points

How come teacher did not add playToken() to handleKeydown()?

In the video, the teacher only codes playToken() method and jump to the demo page. It would be better to mention adding playToken() to handleKeydown() in the video. It could make students confused, although it is easy to catch it.

2 Answers

Steven Parker
Steven Parker
218,812 Points

Your own assessment of "It could make students confused" is probably the best guess as to why it wouldn't be included in the instruction.

But spotting alternatives and potentially more compact/efficient solutions is a good indication of your learning progress and grasp of the material!

I think it was a mistake that they didn't show that part of the challenge. Within Game.js, the handleKeydown(e) method should now look like this, for reference:

     * Branches code depending on what key the player presses.
     * @param {object} e - keydown event object.
    handleKeydown(e) {
        if (this.ready) {
            if (e.key === "ArrowLeft") {
            } else if (e.key === "ArrowRight") {
            } else if (e.key === "ArrowDown") {