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 trial
Konrad Pilch
2,435 PointsChaning to do while
HI,
HI,
I have to trnasform this code :
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.");
into
Im trying this code
var secret = prompt("What is the secret password?");
var password = "sesame";
do{
prompt(secret);
}while( password !== "sesame");
document.write("You know the secret password. Welcome.");
ERROR : Bummer! You only need to call the prompt() method once, and only inside the loop.
I tried a lot, nothing works.
2 Answers
Hugo Paz
15,622 PointsHI Konrad,
Like the message says, you only need to call the prompt method once and inside the loop.
And there's no need for extra variables as well.
var secret;
do{
secret = prompt("What is the secret password?");
}while( secret !== "sesame");
document.write("You know the secret password. Welcome.");
Konrad Pilch
2,435 PointsWe covered it ^^
I dunno , im new to JS : p , i dont know the common mistakes ppl make etc..
Konrad Pilch
2,435 PointsKonrad Pilch
2,435 PointsOh , wow , now it makes sense : p ill gonna need more practice on this . Thank you! :)
Konrad Pilch
2,435 PointsKonrad Pilch
2,435 PointsI got a question, how long would it take me aprox to learn enought JS to make someting useful from my own skill without looking on the videos?
Micole Noddle
5,797 PointsMicole Noddle
5,797 PointsWe haven't learned about do...while loops yet, so something must have changed here (or maybe I'm losing my mind!). I can't get the code above to pass, I keep getting an error saying "Stick with a plain
whileloop for this challenge, not ado...whileorforloop." Totally stuck. And why was a do...while loop passing 8 days ago and isn't passing now?