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

Keytron Brown
Keytron Brown
15,828 Points

Return function

The question for this exercise is a little vague. Can someone help me answer it please?

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?");
do {

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

1 Answer

Hi Keytron, You're really close! It's a little confusing because you need to define the "secret" variable outside of the function but how it's initially defined is what you need to put inside the do loop. You could try defining secret as an empty string (leave it where it is) and add the prompt into your do loop. That way the user will be asked what the secret password is until the condition is met. Hope this helps!