Could someone help in this so short code please?


#1

// I would like to show you the code that I have start today and I do not know where is the problem because it does not recognize me the request of the prompt. If you put my code and you answer to the prompt an anwers with a value that is less than 13 I do not know why it give me the request as you would put a request with a value superior of 13.
If someone could help I would appreciate it so much.

confirm("Do you want to have fun playing?");
var age = prompt("What's your age");
if ("age" < 13) {
console.log("You are allowed to play but we take no responsability");
}
else {
console.log("Ok, there we go");
}

confirm("Do you want to have fun playing?");
var age = prompt("What's your age");
if ("age" < 13) {
    console.log("You are allowed to play but we take no responsability");
} 
else {
    console.log("Ok, there we go");
}

// Thank you so much.


#2

In this line you aren't evaluating the age variable. You have put quotes around age which makes it a text string.


#3

Oh thank you so much by second time. Now I have understood that a var goes with no strings to get the value that the user have given you.
Thank you so much @biff75


#4

Glad you figured it out :slight_smile:


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.