JavaScript JavaScript Basics Making Decisions with Conditional Statements Boolean Values

Yasir alabadi
Yasir alabadi
2,734 Points

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

anthony amaro
anthony amaro
7,617 Points

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