0

Hi what am I doing wrong with this if statement? Ive tried making the second one and else if and the last one an else as well but cant get the alerts to respond properly.

prompt("Please enter a number");
if(x < 100) {
    alert("variable is less 100")
}
if(x == 100) {
    alert("variable is equal to 100!")
}
if(x > 100) {
    alert("variable was greater than 100")
}

thanks!

0

1 Answer 1

7

You are missing an assignment to variable x.

var x = prompt("Please enter a number");
//^^^^^

Then you could use parseInt to get a integer number from the string

x = parseInt(x, 10);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.