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 trialmrx3
8,742 PointsI am completely lost after we create a variable that stores correctGuess = false; Any help would be appreciated
Okay, in the video Dave has us create a variable called correctGuess = false because, when we first start the game we have not guessed anything. Now under the do loop we add correctGuess = true; My first question is, is the reason we put correctGuess = true; in the do loop so that if the user guesses the correct value the program will stop and go to while loop? Next we add ! correctGuess to the while loop which means not true but, because we are using a while loop that actually changes to "is true" and if the user guesses the right answer the two document.write functions "fire."
I could be way off on this because, I'm kind of lost. If someone could correct me and explain this to me I would really, really, really appreciate it. I'm rather new to JavaScript so if you could really break down what's going on here in plain English would also help me a lot. Thank in advance for any help.
1 Answer
Leyton Parker
6,556 PointsYea you got it all right :)
The ! correctGuess changes the
correctGuess = false;
at the the top of the page to
correctGuess = true;
Here is a link to another thread on the same question.
https://teamtreehouse.com/community/dowhile-loop-boolean-question
mrx3
8,742 Pointsmrx3
8,742 PointsThank for the fast reply Leyton, and the link to the same question, much appreciated.
Leyton Parker
6,556 PointsLeyton Parker
6,556 PointsYea no problem, loops can be very confusing, I still struggle with them :)