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 even having trouble following some of the help I am getting but am still getting errors. More help?

I am not understanding some of the symbols used and why ie://?...I am going over the lesson again.

script.js
var secret = prompt("What is the secret password?");
do { var secret=prompt("what is the secret password");
   }
while ( secret !== "sesame" ) {
   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="script.js"></script>
</body>
</html>
Aryaman Dhingra
Aryaman Dhingra
3,536 Points

Which symbols are you talking about?

I realized the forward slashes were only for the comments when I had help from someone...only my code still does not work

Thank you, it has helped a lot...I was wanting to put to much code.

2 Answers

Henrik Christensen
seal-mask
.a{fill-rule:evenodd;}techdegree
Henrik Christensen
Python Web Development Techdegree Student 38,322 Points

You are close:

var secret; // remove prompt here because you will call it in the loop

do {
  // when saying "var secret" here you are creating a NEW variable with the name "secret"
  secret = prompt("what is the secret password?");
} while ( secret !== "sesame" ); // a do-while loop ends here - no more code needed

document.write("You know the secret password. Welcome.");

Thank you, I was adding so much stuff and to boot it was in the wrong place...thanks again for the time