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 if somebody done this can show me how he done it pls i can't see what i do wrong...thx
I need to change the while loop to a do...while loop thx
// This is the code what i have to change in a do loop
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.");
// This is the code what i tried it but still doesn't work is not hard but i can't see what is wrong ...
var secret = prompt("What is the secret password?");
var guess ;
do{
guess = prompt("What is the secret password?");
}
while (guess === "sesame")
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
Raffael Dettling
32,999 PointsHm ok i know the pain ^^ Passed the challenge with this
var guess ;
do{
guess = prompt("What is the secret password?");
}
while (guess !== "sesame")
document.write("You know the secret password.Welcome.");
Raffael Dettling
32,999 PointsYou dont need the variable "secret" and its prompt the variable "guess" does the job and it should run the loop while guess !== sesame :)
Mihia Maftei
1,315 PointsStill the same i lost 3h in this page and i tried a lot to it but is looking like nothing is working... Did you finish it? this task?
Mihia Maftei
1,315 PointsNice now i can look to see what i done wrong the code is working fine i didnt know i can delet that var secret(even if i wanted to delet it still i didn't done the code right) ... you just made my day better thank you !
Raffael Dettling
32,999 PointsRaffael Dettling
32,999 PointsYou will notice itΒ΄s not the last time you will struggle while programming :) Sometimes you just need a break donΒ΄t try to force progress