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 Create a `do...while` loop

I am getting a parse error when running below: where is my syntax off?

I've ran this in treehouse work space and it works fine. It doesn't seem to work under this challenge. Please help!

script.js
let secret;
let password = "sesame";
do {  
  secret = prompt("What is the secret password?");    
} while (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="script.js"></script>
</body>
</html>

I ran your code in my Chrome console and it works fine. Some times the challenges are buggy. I suggest just refreshing the page and trying again.

2 Answers

Steven Parker
Steven Parker
229,788 Points

This is an older course and the parser apparently doesn't understand "let". Use "var" as was originally provided in the code instead.

Thanks everyone. I switched the variable to bar and it worked.

Steven Parker
Steven Parker
229,788 Points

Dhruvan Sampath — Glad to help. You can mark a question solved by choosing a "best answer".
And happy coding!