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 trialMelody Stern
4,039 PointsWhat does the false condition in this loop apply to- what is it evaluating as false?
I don't see a spot where anything is set to this boolean value, so I am confused as to how to evaluate whether or not the condition has been met.
4 Answers
Steven Parker
231,275 PointsYou didn't show which question, but there's a couple of questions in this quiz where "false" is tested directly. Neither one uses it to set a variable, but testing it directly will cause the test to fail.
The quiz is asking you to determine how the code will perform (and what will be output) in that situation.
Melody Stern
4,039 PointsThis is the question I was asking about. I looked up what it means to test a condition without a clear instance of its assignment, and the answer I found on Stack Overflow seemed to indicate that such an instance is testing the statement false against the value true, so it will always return false. In this case, since false is false, and therefore fails the test, why would it return Goodbye in the console log per the answer provided by Treehouse? do { console.log('Hello'); } while (false) console.log('Goodbye');
Steven Parker
231,275 PointsIn a "do" loop, the body is always executed for the first time before the test is performed.
Melody Stern
4,039 PointsGot it. So even though the second statement appears after the while condition is stated, it is still part of the do while loop and is therefore executed once before the while condition is tested?
Steven Parker
231,275 PointsYes, that's right.
Melody Stern
4,039 PointsThank you so much!