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 trialArcee Palabrica
8,100 PointsClarification about while (! isAcceptable);
So we set isAcceptable = false does that mean (! isAcceptable) = true ?
2 Answers
Chris Freeman
Treehouse Moderator 68,457 PointsCorrect! If isAcceptable
is false then (! isAcceptable)
is true.
Mladen Jovanovic
4,662 PointsI was looking for this very question.
I think I got it, but just to check:
The idea of a do-while loop is that it executes the code in the "do" block until the expression in "while()" evaluates to "false" (essentially: keep doing this as long as the condition is true), right?
So, in our case, we have the "isAcceptable" boolean set to "false" and the statement in "while" is going to be true as long as "isAcceptable" stays false, right?
Meaning that the only way to stop the loop is for a letter to pass the validation and normalization, which would change "isAcceptable" to true, which would make the expression in "while()" false?
Sorry if this is redundant, but this actually broke my brain for a while, especially since I wasn't entirely sure how do-while worked. :)
Chris Freeman
Treehouse Moderator 68,457 PointsYour understanding is correct!
Mladen Jovanovic
4,662 PointsGreat! Thanks a lot for the feedback.
Arcee Palabrica
8,100 PointsArcee Palabrica
8,100 PointsThanks Chris. So in the do-while loop does it mean that as long as isAcceptable is false it will keep on looping until it flips to true? Right?
Chris Freeman
Treehouse Moderator 68,457 PointsChris Freeman
Treehouse Moderator 68,457 PointsCorrect again! "Do until something is acceptable"