JavaScript JavaScript Loops, Arrays and Objects Simplify Repetitive Tasks with Loops Create a `do...while` loop

Michael Walter
Michael Walter
2,094 Points

I don’t understand the error

It looks correct to me, but I must be missing something. Can I have another set of eyes take a look for me? Thanks.

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

1 Answer

Brandon Leichty
Brandon Leichty
Full Stack JavaScript Techdegree Graduate 29,590 Points

Hey Michael,

Give this a try:

var secret;
do {
   secret = prompt("What is the secret password?");
   }while ( secret !== "sesame" );
document.write("You know the secret password. Welcome.");

Hope that helps!

Michael Walter
Michael Walter
2,094 Points

Thank you very much, it truly is apprecited. :-)