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.

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