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

JavaScript JavaScript Loops, Arrays and Objects Simplify Repetitive Tasks with Loops Review while loops, do...while loops, and Loop Conditions

Melody Stern
Melody Stern
4,039 Points

What 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
Steven Parker
231,236 Points

You 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
Melody Stern
4,039 Points

This 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
Steven Parker
231,236 Points

In a "do" loop, the body is always executed for the first time before the test is performed.

Melody Stern
Melody Stern
4,039 Points

Got 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?

Melody Stern
Melody Stern
4,039 Points

Thank you so much!