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 trialKarl Wills
4,110 PointsBummer! Your code took too long to run.
I can't seem to get past this quiz, am I doing something wrong? The code seems to work fine in a CodePen.
var secret;
while(secret !== "seasme") {
secret = prompt("What is the secret password?");
}
document.write("You know the secret password. Welcome.");
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JavaScript Loops</title>
</head>
<body>
<script src="app.js"></script>
</body>
</html>
1 Answer
YI LI
4,094 PointsHello Karl, 1.You misspell "sesame" to "seasme" 2.It is better to give secret an initial value var secret=""; Hope it helps.
Karl Wills
4,110 PointsKarl Wills
4,110 PointsThank you for your help. The misspell must have been causing the issue :)
Could you explain why it would be better to give secret an initial value instead of just declaring the variable? I was under the impression that it did the same thing.
Thanks again for your help.
YI LI
4,094 PointsYI LI
4,094 PointsYou are welcome. It is just my own opinion. In Javascript, all types of variables are declared as var. By declaring var secret=""; , I can easily to know the type of variable in the beginning when the second secret is too many lines away from the first.