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
Why 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
Steven Parker225,664 Points
There 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.
because 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?