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

Tsipporah Christopher
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Tsipporah Christopher
Full Stack JavaScript Techdegree Graduate 15,593 Points

Why do I keep getting an error with my code?

Here is my code. Can someone please advise me on what I am doing wrong for this do...while loop challenge? Thank you.

script.js
// Display the prompt dialogue while the value assigned to `secret` is not equal to "sesame"
let secret = prompt("What is the secret password?");
const password = "seseme";

//check the passwrd, if it is false (secret !== seseme), run the alert prompt, until secret = seseme
do {
  secret = prompt("What is the secret password?");
} while ( secret !== password );

// This should run after the loop is done executing
alert("You know the secret password. Welcome!");

2 Answers

Great work, you've solved the challenge. There's a simple change to make in there to get the "Check Work" test to pass your solution.

Read the last line of the requirements very carefully:

Add a do...while loop that keeps displaying the prompt dialog until the user types 'sesame'.