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

JavaScript JavaScript Loops, Arrays and Objects Simplify Repetitive Tasks with Loops Create a `do...while` loop

for the do...while loop challenge, my code is taking too long to run. Is this because its wrong?

my code looks like:

var secret;
var sesame;
var correctGuess = false;
do {
  secret = prompt("What is the secret password?");
  if (secret === sesame) {
  correctGuess = true;
  }
}
while ( ! correctGuess )
document.write("You know the secret password. Welcome.");

4 Answers

Hi Dale, thanks! Sadly, I find I don't understand what you mean. I added:

var sesame = answer;

but then it couldn't find the variable answer. Please will you elaborate? Thank you.

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hey Viki.

Your code is correct, except for one small thing: you are missing the quotes around sesame to make it a string.

if (secret === "sesame") {         -- added quotes

Keep Coding! :)

Thnk you Dale! Now I get it.

Thanks Jason! I had the quotes at one point but must have had something extra 'cuz it didn't work, but that works, yay!