Please Heeeeelp... ( WHILE LOOP)

Your editor currently has a variable declared target to which a random number between 0 and 10 will be assigned. Print the target to the console.

Write a small program which will keep guessing numbers between 0 and 10 and printing them until the guessed number is the same as the target.


var target = Math.floor(Math.random() * 11);
var guess = Math.floor(Math.random() * 11);


while ( guess !== target);{
    console.log("try again");
    guess = Math.floor(Math.random() * 11);


Code is incorrect

unknown error

Should there be a semi-colon in this while statement?

No semi colon should appear in the first line of the while condition, and your quotes in the console log seem to be “formatted”. Try to re-type them, or comment out that line and see if your code works.

They appear like that because the OP didn’t quite paste their code in here correctly.

To display your code in here you need to wrap it in triple back ticks. On a line by itself type three back ticks. Then on the first line below the three back ticks paste in your code. Then below your code on a new line type three more back ticks. The back tick on my keyboard is in the upper left just above the Tab key and below the Esc key.

If they would have done that then the quotes would appear as regular ascii quotes.

Mod edit: solution redacted

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.