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 trialRonald Ashby
2,878 PointsCorrupt Challenge: no correct code answer for the do ...while (secret) challenge.
Declared var secret; first, and placed prompt in while loop and the do...while fails. Works fine offline in text editor.
var secret;
do {
secret = prompt("What is the secret password?");
} while ( secret !== "sesame" );
document.write("You know the secret password. Welcome.");
var secret = prompt("What is the secret password?");
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>
4 Answers
Jason Anders
Treehouse Moderator 145,860 PointsHey Ronald,
I added markdown to the first part of the code you posted so it can be read. It looks like xela888 didn't see this, as your code is correct and is exactly what the challenge asked for.
I copied and pasted the first snippet that you already had written and it passed the challenge. So, it may have just been a glitch in the challenge. If you haven't passed it yet, just copy your code snippet into (and overwriting) the pre-loaded code of the challenge, and you're good to go. Keep Coding!
Alexander Davison
65,469 PointsThis code works, but this challenge is asking you to replace the while loop into a do-while loop. You should review the video, but if you just want the answer now, here:
var secret;
do {
secret = prompt("What is the secret password?");
} while ( secret !== "sesame" )
document.write("You know the secret password. Welcome.");
Please review the video to learn the difference (because I don't want to waste time on this, I want to help more people)
Hope it helps! ~xela888
Ronald Ashby
2,878 PointsThanks! First challenge I've had where you replace the pre-loaded code.
stjarnan
Front End Web Development Techdegree Graduate 56,488 PointsJust like Xela said, it asks you to convert the code into a do while loop. I won't post a code example as Xela did that perfectly.
Ronald Ashby
2,878 PointsRonald Ashby
2,878 PointsThanks! That's the first challenge I've had where you replace the pre-loaded code.