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 moveLeft() and moveRight() Methods Solution

George Roberts
seal-mask
.a{fill-rule:evenodd;}techdegree
George Roberts
Full Stack JavaScript Techdegree Student 8,474 Points

Why does ```this.html.style.left``` hold an integer, and not a string value with 'px' included?

Hi, Below is my attempt at the moveLeft() method. I thought that this.html.style.left would need to hold a string because the units (pixels) need to be included. Am curious why that's not necessary in this case? Thanks

moveLeft(){
    if (this.columnLocation > 0) {
      this.htmlToken.style.left = (this.offsetLeft - 76) + 'px';
      this.columnLocation -= 1;
    }
  }

good question, unfortunately I don't know the reason either. It seems to be added automatically. When I inspect the element with the chrome developer tools it does have the 'px' added even though I did not explicitly add them myself.

Although if i edit it manually in the dev tool it also works if i leave out the px.