0
Hi folks ! how can I create a prompt to know if the person is 18+?
4 ответов
+ 2
var userAge = prompt("Enter your age");
(userAge<=18)?alert("Child"):alert("Adult");
+ 1
Try to do that and share your code If you have problems.
You must to get an integer value and check that with an If and else and show maybe an alert
+ 1
your var is p so you must to change var<18 for p<18 and delete var age=18
0
var p= prompt ("age");
var age = 18;
if (age < 18)
{
alert("child");
}
else
{
alert("adult");
}
//lake this ?