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!
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

Swan The Human
Full Stack JavaScript Techdegree Student 19,338 PointsWhy is it this.board.rows -3?
I understand the if statement because it adds to the x or y axis by one to manually iterate through the spaces. but i'm not sure why in the for loop it says -3
1 Answer

Steven Parker
225,664 PointsThere are four separate tests combined together in the conditional expression, one of which looks 3 cells ahead (+3). So the loop must compensate by stopping 3 before the end (-3) to prevent trying to access cells beyond the range.
Trevor Maltbie
Full Stack JavaScript Techdegree Graduate 17,018 PointsTrevor Maltbie
Full Stack JavaScript Techdegree Graduate 17,018 Pointsbecause the last check in the loop is x+3 which could then run to a max of 7 which is the amount of columns. Correct?
Steven Parker
225,664 PointsSteven Parker
225,664 PointsThe board only has 4 columns.