Two other alternatives...
1st based upon posted code...
<HTML>
<HEAD>
<SCRIPT>
var age = parseInt(prompt("Please enter your age:",''));
var tooOldYoung = true;
if (age < 21) {
alert("Sorry, you are too young to enter");
} else {
if (age > 21) {
alert("Sorry, you are too old to enter");
} else { tooOldYoung = false; }
}
if (!tooOldYoung) {
alert ("Welcome to our exclusive club");
location.href = "http://www.houstonian.com";
}
</SCRIPT>
</HEAD>
<BODY>
</BODY>
</HTML>
2nd with a different approach...
<HTML>
<HEAD>
<SCRIPT>
var age = parseInt(prompt("Please enter your age:",''));
var tooOldYoung = (age < 21) ? -1 : (age > 21) ? 1 : 0;
switch(tooOldYoung) {
case -1 : alert("Sorry, you are too young to enter"); break;
case 1 : alert("Sorry, you are too old to enter"); break;
default : alert ("Welcome to our exclusive club");
location.href = "http://www.houstonian.com";
break;
}
</SCRIPT>
</HEAD>
<BODY>
</BODY>
</HTML>