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.

JavaScript JavaScript Basics (Retired) Making Decisions with Conditional Statements Boolean Values

Boolean Values- Uncaught SyntaxError: Unexpected end of input

Hey, So I have added Boolean Values, the code was working on conditional statements prior.

since adding Booleans, developer tools telling me 'Uncaught SyntaxError: Unexpected end of input' on the 'else' syntax

where am i going wrong here?

var correctNumber= false; 

var randomNumber= Math.floor(Math.random() *6 ) +1; 

var userResponse= prompt('Can you guess the number? lets see..');

if (parseInt(userResponse) === randomNumber) {
  correctNumber= true;

  if (correctNumber===true) {

    alert('Well done!');

}  else {

  alert('oh no try again'); 

1 Answer

hello yashir. you are missing a bracket at the end of your code. since you set correctNumber to true. you dont need to check if correctNumber === true. you can just do it like this

if (parseInt(userResponse) === randomNumber) {
   correctNumber= true; // you are updating the value if this statement runs

  if(correctNumber) { // you know this will be true


hope this helps