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 trialBrooke Guy
8,179 PointsThere was an error with your code: SyntaxError: Parse error
This is the error I am getting: There was an error with your code: SyntaxError: Parse error
var secret = prompt("What is the secret password?");
while ( secret !== "sesame" ) {
do (secret = prompt("What is the secret password?"));
}
document.write("You know the secret password. Welcome.");
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JavaScript Loops</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>
1 Answer
Grace Kelly
33,990 PointsHi Brooke, you're on the right track, however a do while loop is written in the following way:
do {
console.log("i'm doing this");
} while (a !== b)
Also you don't need to declare your secret var twice, just once before the do while loop :)
Hope that helps!!
Dávid Molnár
27,081 PointsDávid Molnár
27,081 PointsAren't you supposed to write a:
loop?
if that's the case you need to change the order of do and while.
you can change the do-while for a simple while it's not neccessary there and try to use console.log() for printing results in the console (in browser press "crtl + shift + I => console panel)