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

Ben Linnenbank
Ben Linnenbank
6,438 Points

super stuck

can't get it to work

script.js
var secret = "sesame";
var correctGuess = false;
var guess;

do {
  guess = prompt("What is the secret password?");
  if (guess === secret) {
    correctGuess = true;
  } while ( ! correctGuess );
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>

2 Answers

Keneth Ade
Keneth Ade
4,213 Points

You are missing a closing curly brace at your do statement.

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

Ben Linnenbank
Ben Linnenbank
6,438 Points

i figured i missed the curly braces after 20 minutes ><