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, Arrays and Objects Simplify Repetitive Tasks with Loops A Closer Look At Loop Conditions

Karl Wills
Karl Wills
4,110 Points

Bummer! 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.

app.js
var secret;

while(secret !== "seasme") {
  secret = prompt("What is the secret password?");
}

document.write("You know the secret password. Welcome.");
index.html
<!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
YI LI
4,094 Points

Hello Karl, 1.You misspell "sesame" to "seasme" 2.It is better to give secret an initial value var secret=""; Hope it helps.

Karl Wills
Karl Wills
4,110 Points

Thank 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
YI LI
4,094 Points

You 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.