Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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
210,475 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
210,475 Points

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