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 trialMihia Maftei
1,315 PointsHi i am a wee confuse with this code can somebody help me thx i have to creat a do...while loop
Is do...while loop thx
var secret = prompt("What is the secret password?");
var correctGuess = false;
do {
secret = prompt("What is the secret password?");
if (secret === "sesame") {
correctGuess = true;
}
}
while ( secret !== "sesame" ) {
secret = prompt("What is the secret password?");
}
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>
2 Answers
Jason Anders
Treehouse Moderator 145,860 PointsHi Mihia,
You are on the right track, but you can't have an if statement
inside of a do/while
loop. A do/while
loop has two main parts to its syntax. => 1. Do something ... 2. While something is True. Have a review of the video for do while
loops with this in mind, and pay close attention to the syntax used. I think you should be able to get it after that.
Keep Coding! :)
Mihia Maftei
1,315 PointsHi i done something else but i am still confuse i kinow is not a big deal but i don't know how i cant see it... i posted another one