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 trialSeth Pabst
10,285 Pointsdont get it
in a previous question to this quiz the while loop didn't run because the condition was (false), i thought it had to be (true) to run. But in this example it runs when (false)??
2 Answers
Steven Parker
231,236 PointsThe difference between a "while" and a "do...while" is that in a "do...while", the code runs first, and then the condition is tested to see if should repeat. So even when the condition is already false, the code block will run one time.
Joe Beltramo
Courses Plus Student 22,191 PointsI am not sure which question you are referring to, since it doesn't tell you in the creation of a question. I can only assume it's this one?
Given the code below, what will print out to the console?
do {
console.log('Hello');
} while (false)
console.log('Goodbye');
If so, this runs because in a do...while
statement, the do always runs at least once before it checks the while statement. Had the while statement been true
, it would run until the while statement became false due to a conditional statement in the while loop, or run Infinitely.
Is that the question? If not, please provide the question...