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 trialMIHA W.LEE
PHP Development Techdegree Graduate 25,452 PointsWhile loop
First of all, I know how While loop behaves. It means when the condition statement is true, it will keep running. If not true, it will stop.
But in this tutorial, i cant understand the logic behind the while loop. Is that means if the time is below 8000, it should printout much more 'finished' string. Then after 8000miliseonds it appear one result.
I just dont know the logic behind it.
Hope someone can help me out, thank you so much!
1 Answer
Steven Parker
231,269 PointsIf you look closely, you can see that the "while" statement has a semicolon (";") at the end of it. This means that loop has an empty body, so there is no code that is executed when the condition is true.
So the loop does nothing but keep testing the condition. It essentially just "waits" for the condition to be false, which will occur after 8 seconds (8000 milliseconds).
The log statement comes after the loop and is only done once after the loop finishes.
MIHA W.LEE
PHP Development Techdegree Graduate 25,452 PointsMIHA W.LEE
PHP Development Techdegree Graduate 25,452 PointsOh......I totally missed that. Thank you so much!!