0

var age = '16';
prompt(enter 'age');
if (age > 17) {
  alert("good to drive");
} else {
  alert("sorry you are not eligible");
}
Dharman
  • 26,923
  • 21
  • 73
  • 125

2 Answers2

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
  • 356
  • 1
  • 14
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
  • 669,327
  • 51
  • 454
  • 560