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 trialZaal Rottunda
Full Stack JavaScript Techdegree Student 1,796 PointsInfinite Loops Quiz: Given the code below, what will print to the console?
I have tried every answer on this question but am constantly told it is wrong. Not sure if a bug, but I thought the answer should be 'goodbye'.
while (false) { console.log('Hello'); } console.log('Goodbye');
Rohald van Merode
Treehouse StaffHey Zaal Rottunda 👋
You've posted this question in the general JavaScript discussions so I'm not entirely sure what quiz you're referring to. Could you please share a link to the quiz you're working on?
Since you're enrolled in a Techdegree you could also reach out to our Slack channels. We got dedicated staff and moderators available there throughout the day and are more likely to get a speedy response over there 🙂
2 Answers
Rohald van Merode
Treehouse StaffThanks for sharing a link to the quiz! Looks like there are no duplicates in the quiz. First one is a do...while
-loop:
do {
console.log('Hello');
} while (false);
console.log('Goodbye');
For this question the do
part of the loop will always run, no matter the condition. Therefor the result for this one will be: Hello Goodbye
The other question is the snippet you shared above, which is a while
-loop.
while (false) {
console.log('Hello');
}
console.log('Goodbye');
This block will only run while the conditional evaluates to be true. Since false
will never evaluate to be true, the code inside will not run and the answer for this question is indeed: Goodbye
Hope this clears things up! 😃
Zaal Rottunda
Full Stack JavaScript Techdegree Student 1,796 Pointsoh wow......I need to slow down in my reading lol, thanks!
Zaal Rottunda
Full Stack JavaScript Techdegree Student 1,796 PointsZaal Rottunda
Full Stack JavaScript Techdegree Student 1,796 PointsThe question is also listed twice in the quiz so I can't pass bc it doesn't accept any answer as correct. HELP