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 Simplify Repetitive Tasks with Loops Review while, do...while, and Loop Conditions

Never told what the input was

In JavaScript Loops, we are never told what the input is so how are we supposed to figure out what the output will be? while (false) { console.log('Hello'); } console.log('Goodbye');

1 Answer

Hi Kevin,

For the quiz question that you've posted, the condition in the while loop will never evaluate to true, as false is NOT true. Therefore, the code within the code block will never run. Essentially, the console.log('Hello'); is unreachable code. If that doesn't make sense, let me know and I'll try to explain it.

Anyhow, because the console.log function inside the code block will never run, 'Hello' will never print to the console. The statement that appears after the while loop is console.log('Goodbye'). Because that second console.log function is outside of the loop, it will run and 'Goodbye' will be printed to the console.

Hope this helps you to figure out the correct answer.