var age = '16';
prompt(enter 'age');
if (age > 17) {
alert("good to drive");
} else {
alert("sorry you are not eligible");
}
Asked
Active
Viewed 346 times
0

Dharman
- 30,962
- 25
- 85
- 135

Shubham Saini
- 17
- 3
2 Answers
1
You had a few syntax errors but here's a patched up version:
var age = prompt("Please enter your age"); // Gets input
if (age > 17) {
alert("Good to drive.");
} else {
alert("Sorry you are not eligible.");
}

Kenzoid
- 276
- 1
- 16
0
The first two lines should be:
var age = prompt('enter age');
The whole argument to prompt()
has to be in quotes, and you need to assign the result to the variable so you can use it in the if
statement.

Barmar
- 741,623
- 53
- 500
- 612