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 trialJennifer Martin
3,829 PointsI don't know where to begin with this, completely lost...
// Display the prompt dialogue while the value assigned to `secret` is not equal to "sesame"
let secret = prompt("What is the secret password?");
let secret;
do {
secret= prompt // code to run
}
while ( password !== 'abc123' );
do {
// This should run after the loop is done executing
alert("You know the secret password. Welcome!");
2 Answers
martinjones1
Front End Web Development Techdegree Graduate 44,824 PointsThe code below will pass the challenge:
// Display the prompt dialogue while the value assigned to `secret` is not equal to "sesame"
// Declare the variable secret to store the value from the prompt
let secret;
do {
// The secret variable will be updated with the value from prompt
secret = prompt("What is the secret password?");
// If secret is not equal to 'sesame', call the prompt again and update the value of secret
} while (secret !== 'sesame');
// This should run after the loop is done executing
alert("You know the secret password. Welcome!");
lets also look at your existing code and breakdown what is happening here.
// Display the prompt dialogue while the value assigned to `secret` is not equal to "sesame"
let secret = prompt("What is the secret password?");
let secret; // This will result in the error - "Uncaught SyntaxError: Identifier 'secret' has already been declared", because you have already declared secret on the line above
do {
secret= prompt // code to run - // Prompt is not being invoke/called, so this will l
}
while ( password !== 'abc123' ); // Looks good, just need to update the password to be 'sesame' to pass the challenge
do { // We can remove this line here is this is not doing anything and will result in a Syntax error
// This should run after the loop is done executing
alert("You know the secret password. Welcome!");
I think you were close to be honest, hopefully the examples above help
Jennifer Martin
3,829 PointsThank you so much, I was really ready to give up on becoming a web developer all together. I am great with CSS and HTML, but I am floundering with JavaScript big time.
martinjones1
Front End Web Development Techdegree Graduate 44,824 PointsYou are welcome, I still struggle with JavaScript myself, especially when learning a new concept, I find that something just clicks with me eventually on it as well, so this feeling is normal I feel.
Lastly, I think that knowing CSS and HTML is a real positive as well, I know plenty of developers who are good with JavaScript but don't fully understand CSS or HTML ^_^
Hope you stick with it, all the best,
Martin