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.

Ben Bushell
8,952 PointsmoveRight() alternative, would this cause an issue?
moveRight(){
if (this.columnLocation < game.board.columns - 1) {
this.htmlToken.style.left = this.offsetLeft + 76;
this.columnLocation += 1;
}
}
I handled the column amount within my method rather than passing it as an argument. Tested and it works fine but just wondering it anyone can think of any possible issues with this solution?
2 Answers

Steven Parker
220,634 PointsI think you've answered your own question!
You could, however, pass in the game object and still access the columns in the function:
moveRight(game){
if (this.columnLocation < game.board.columns - 1) {
this.htmlToken.style.left = this.offsetLeft + 76;
this.columnLocation += 1;
}
}

Ben Bushell
8,952 PointsBrill thanks Steven, nice to have some confirmation :)

Trevor Maltbie
Full Stack JavaScript Techdegree Graduate 17,005 PointsHow did you test it? At this point in the project my game doesn't do anything.
Ben Bushell
8,952 PointsBen Bushell
8,952 PointsI think I may of thought of one possible issue;
const game = new Game();
if the variable name for the game was changed in the app file then this solution would no longer be able to call this;
game.board.columns
as it would only search for a game with the variable name 'game'.