Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript Loops Simplify Repetitive Tasks with Loops Create a do...while loop

Tsipporah Christopher
Tsipporah Christopher
1,786 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.

// 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'.
Tsipporah Christopher
Tsipporah Christopher
1,786 Points

Oh I came back to it today and noticed the typo in sesame haha >.< Thank you so much!!