0

Hi folks ! how can I create a prompt to know if the person is 18+?

18th Oct 2017, 11:32 PM
Victor
Victor - avatar
4 Respuestas
+ 2
var userAge = prompt("Enter your age"); (userAge<=18)?alert("Child"):alert("Adult");
19th Oct 2017, 12:14 PM
henok
henok - avatar
+ 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
19th Oct 2017, 12:22 AM
Daniel
Daniel - avatar
+ 1
your var is p so you must to change var<18 for p<18 and delete var age=18
19th Oct 2017, 11:59 AM
Daniel
Daniel - avatar
0
var p= prompt ("age"); var age = 18; if (age < 18) { alert("child"); } else { alert("adult"); } //lake this ?
19th Oct 2017, 8:44 AM
Victor
Victor - avatar