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 trialBen 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
231,261 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,021 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'.