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 Simplify Repetitive Tasks with Loops Create a do...while loop

Problem with do-while loop solution

I'm having trouble figuring out where to go from here. I've rewatched the videos and gone to StackOverflow.

script.js
// Display the prompt dialogue while the value assigned to `secret` is not equal to "sesame"
let secret;
do {
  let secret = prompt("What is the secret password?");
} while (secret !== 'sesame')

// This should run after the loop is done executing
alert("You know the secret password. Welcome!");
Lisa Walters
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Lisa Walters
Front End Web Development Techdegree Graduate 15,255 Points

Hello James! I only know that your code works as long as it is linked to an html file. The only thing that I can see is that you don't need to repeat the "let" the second time you state "secret". Hope that helps! Good luck!

3 Answers

Remove let inside the do while loop.

It worked fine for me, just tested it. Hmm.... Could you post your updated code?