Assignment017a

If-Else

This Web page prompts visitors for their age. Once the age is entered, it is sent to a JavaScript function located in the head of the Web page. Depending on the age of the user, the function creates a response appropriate for the age entered. Here's the code used to create the function in the head section of the Web page:

<script>

function checkage(age)
{
if (age<=13)
{
window.document.write("You're to young for this.");
}
else
{
window.document.write("Welcome Person! :)");
}
}

Here's the code used to prompt users for their age (located in the body of the document):

</script>


var age;
age=prompt("How old are you?", "");
checkage(age);

</script>