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 trialMarc Christiansen
1,744 PointsWhat should I change here?
Hi all.
I don´t understand why this wont work. What do i need to include or type different? Thanks
do {
secret = prompt("What is the secret password?");
// code to run
}
while ( secret !== 'sesame') {
alert("You know the secret password. Welcome!") };
2 Answers
Thomas Davidson
7,243 PointsHi Marc,
You're really close to solving the challenge.
I tried you're code in the challenge and got the error
ReferenceError: Strict mode forbids implicit creation of global property 'secret'
Because the challenge is in strict mode you need to declare the variable secret
.
Here's some info on strictmode
The variable must be declared outside of the function and doesn't need to be given any kind of value yet.
let secret;
do {
secret = prompt("What is the secret password?");
// code to run
}
while ( secret !== 'sesame') {
alert("You know the secret password. Welcome!") };
Hope that helps!
Marc Christiansen
1,744 PointsThanks for your help :-)
Jamie Moore
3,997 PointsJamie Moore
3,997 PointsHey Marc, what issues are you having with the code? I just ran it in my console and it asked me for a password, if I enter 'sesmame', I get notified I know the password. What else would you like the code to do?