Assignment017

If-Statements

This Web page prompts visitors for their age. Once the color is entered, it is sent to a JavaScript function located in the head of the Web page. If the age is less than 15 the function creates a response appropriate for that age. The response is displayed below:

<script>

function checkage(age) {
window.document.write(" Hello! ");

if (age<=15)
{ window.document.write("

You're to young for this.

"); } }

</script>

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

<script>

var age;
age=prompt ("What is your age?");
checkage(age);

</script>