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

Different approach for moveLeft() and moveRight()

/** 
     * Moves html token one column to left.
     */
    moveLeft() {
        if( this.columnLocation > 0 ) {
            this.columnLocation -= 1;
            this.htmlToken.style.left = 76 * this.columnLocation;
        }
    }

    /** 
     * Moves html token one column to right.
     * @param   {number}    columns - number of columns in the game board
     */
    moveRight(columns) {
        if( this.columnLocation < columns - 1 ) {
            this.columnLocation += 1;
            this.htmlToken.style.left = 76 * this.columnLocation;
        }
    }

I simply multiplied the columnLocation with 76 to set the correct position. Note that it is important to update the columnLocation BEFORE multiplying or else your token moves in weird ways.

// EDIT this was supposed to be in the discussion thread for this video https://teamtreehouse.com/library/moveleft-and-moveright-methods-solution