## Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

### Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today. # 'do.. while' loop. I'm doing something wrong... not sure what.

I wrote out this code and I have been testing it out. No matter what answer I enter the answer is always right. I've been moving the code around a bit, I figured the document.write would only trigger if I put it inside of the if conditional statement, but evidently that didnt make a difference. Any ideas?

var randomNumber = getRandomNumber(10); var guess; var guessCount = 0; var correctGuess = false;

function getRandomNumber(upper) { var num = Math.floor( Math.random() * upper ) + 1; return num; }

do { guess = prompt('I am thinking of a number between 1 and 10. What is it?'); guessCount += 1; if (parseInt(guess) === randomNumber); { correctGuess = true;
document.write('<p> you guessed right! </p>'); } } while ( correctGuess = true ) There are following problems.

1. Omit ';' before '{' in this code if (parseInt(guess) === randomNumber); {
```if (parseInt(guess) === randomNumber) {
correctGuess = true;
document.write('<p> you guessed right! </p>');
}
```
1. you need double or triple '===' in bolleans. so correct bollean statement. also you want zour loop run while correct Guess is false not true so correct boolean should be likebottom. and also add ';' at the end of the statement.
```while ( correctGuess === false );
```

FULL corrected code

```var randomNumber = getRandomNumber(10);
var guess;
var guessCount = 0;
var correctGuess = false;

function getRandomNumber(upper) {
var num = Math.floor( Math.random() * upper ) + 1;
return num;
}

do {
guess = prompt('I am thinking of a number between 1 and 10. What is it?');
guessCount += 1;

if (parseInt(guess) === randomNumber) {
correctGuess = true;
document.write('<p> you guessed right! </p>');
}

} while ( correctGuess === false );
``` ```} while ( !correctGuess );