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 trial

PHP PHP Basics (Retired) PHP Conditionals & Loops For Loops

Shazad Kazi
Shazad Kazi
10,758 Points

At 5:29, shouldn't the code run 21 times as you are starting with 0 and going to 20 inclusive.

Questions sums it up.

I believe its an error that should be fixed.

2 Answers

The code does run 21 times. Originally when he switches screens he has the old code that ran till 10. He then refreshes the page and you can see it update to show 0 to 20, which is 21 times. This always confuses me, and I have to think that if it was 0 through 2, then it ran 3 times (2 + 1), so 0 to 20 would be 21 times (20 + 1).

Adam Fournace
PLUS
Adam Fournace
Courses Plus Student 4,115 Points

Runs / Index 1 == 0 2 == 1 3 == 2 4 == 3 5 == 4 6 == 5 7 == 6 8 == 7 9 == 8 10 == 9 11 == 10 12 == 11 13 == 12 14 == 13 15 == 14 16 == 15 17 == 16 18 == 17 19 == 18 20 == 19 21 == 20