Welcome to the Treehouse Community
Looking to learn something new?
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!
Steven Parker215,984 Points
If 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.