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

JavaScript JavaScript Loops, Arrays and Objects Simplify Repetitive Tasks with Loops For Loops

Blake Powell
Blake Powell
4,175 Points

Wrong answer

so no clue what the right answer is for the previous code challenge, but pretty sure my 20th guess -

var secret = "" do {secret += prompt("What is the secret password?";}
while ( secret !== "sesame" )

document.write("You know the secret password. Welcome.");

will never be correct unless you guess it right the first time. however it passes the challenge. not my first questionable response to a code challenge, and by far not the first that i couldn't figure out after going back and watching the videos about half a dozen times.

Blake Powell
Blake Powell
4,175 Points

correction, that was a retype, since it was two late to copy var secret = "" do (secret += prompt("What is the secret password?"))
while ( secret !== "sesame" )

document.write("You know the secret password. Welcome.");

1 Answer

Steven Parker
Steven Parker
229,788 Points

It looks like you found a bug.

You're right, with "secret += ..." only the first try would count.
That should be just a plain assignment: "secret = ...".

The instructions for reporting a bug can be found on the Support page.

Also, when posting code, please use the instructions for code formatting in the Markdown Cheatsheet pop-up below the "Add an Answer" area. :arrow_heading_down: