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

Kim Dallas
Kim Dallas
11,461 Points

it didn't work

what am I doing wrong?

script.js
var secret;
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

You have closed the prompt function bracket INSIDE the string, so the function is not actually closed and does not work. This is why the close bracket is a different colour to the open bracket. The colours are there to help you.