Java script


#1

Im in my first year of uni and attempted to write some java script but it doesnt work. can anyone see why?

<h1> Eligibility </h1>

<script>
function myFunction() {
   var x = parseFloat(document.getElementById("input1").value);
   var greeting;
   
    if (Age < 18) {
        greeting = "Not Old Enough";
    } else {
        greeting = "Great! sign up";
    }
    document.getElementById("result").innerHTML = greeting;
}
</script>

Age: <input type="text" id="input1" size="4"/> 

<button onclick="myFunction();" type="button">Eligible?</button>

<p id="result"></p>

#2

here:

if (Age < 18)

where did you define Age? i don’t see it being defined anywhere


#3

I’d been looking at the code too long. I fixed it eventually. Thanks though :slight_smile:


#4