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
Tani Huang
6,952 PointsAre these two codes the same ? (do...while)
1)
var secret;
while ( secret !== "sesame" ) {
secret = prompt("What is the secret password?");
}
document.write("You know the secret password. Welcome.");
2) do { var secret = prompt ("What is the password"); } while ( secret !== "hello"); document.write("You know the secret password. Welcome.");
1 Answer
Steven Parker
243,228 PointsNo, in example 1 the correct response is "sesame", but in example 2 it is "hello".
But seriously, other than the expected word and the prompt wording, those two snippets appear to be functionally the same.
One of "Parker's Rules of Programming" is "The more complex the task, the more ways there will be to arrive at a solution".