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 trialAdam Fields
4,487 PointsThis is the code we used in the last code challenge. After learning about do...while loops, don't you think this would w
I think I added the conditions correctly in that will print welcome or will print try again in the while loop if the do section doesnt run what am I doing wrong
var secret = prompt("What is the secret password?");
var count=0;
var correctGuess;
do{
if(correctGuess===true){
document.write("try again");
}
}
while ( secret !==false )
document.write("You know the secret password. Welcome.");
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JavaScript Loops</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>
David Evans
10,490 PointsDavid Evans
10,490 PointsYou have an endless loop right now as correctGuess is uninitialized and is never updated.
If you want to use the correctGuess variable you can try something like this (following the challenge's previous code):
Below is probably what they're looking for without your modifications of an extra variable: