<html>
<body>
<script>
var age=prompt("what's your age")
var gen=prompt("what's your gge")
if
(age>=21 && gen=male) || (age>=18 && gen=female)
{
document.write("eligble")
}
else
{
document.write("not eligble")
}
</script>
</body>
</html>
01-15-2013, 12:17 PM
Sup3rkirby
With your if statement grouping, you are missing an extra parenthesis for each pairing which breaks that if statement.
Also the comparison of the gen variable needs to use the == comparison operater (just a single = sets a variable, 2 or 3 = signs will compare).
And the male and female comparison strings much be enclosed in some form of a quote.
It also would be proper practice to use semi-colons at the end of each proper line of code:
Code:
<html>
<body>
<script>
var age=prompt("what's your age");
var gen=prompt("what's your gge");
if((age>=21 && gen=="male") || (age>=18 && gen=="female")) {
document.write("eligble");
} else {
document.write("not eligble");
}
</script>
</body>
</html>
01-15-2013, 12:26 PM
leonight
tons of thanks sir problem solved and i have learned something very important:)