-4
var age1 = 30;
        if(age1 >= 13 && age1 <= 19){
            message = "You are a teenager";
            }else{
                message = "You are not a teenager";
            }

This code is pretty self explanatory, but when I run it in html It does not work, I don't know why. It does not give me any of the messages when run in HTML.

7
  • where do you use message ? Commented Feb 14, 2019 at 10:51
  • what output did you expect? Commented Feb 14, 2019 at 10:51
  • 1
    Have you tried doing console.log("text here"); instead of mesage = "text here" Commented Feb 14, 2019 at 10:52
  • I expected it to output "You are not a teenager" because age1 is not within the 19-13 range. Commented Feb 14, 2019 at 10:52
  • @JakeWatson — But your code assigns the string to a variable, it doesn't do anything to output it. Commented Feb 14, 2019 at 10:53

1 Answer 1

2

Use console.log to print the message

var age1 = 30;
if (age1 >= 13 && age1 <= 19) {
  message = "You are a teenager";

} else {
  message = "You are not a teenager";

}
console.log(message)

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.