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 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