CSci 1001 Lab 5

Due Monday Nov 11 at 11:59pm.

JavaScript Functions


Carefully study the examples on the resources page: A function to convert from celsius to fahrenheit, Calling a function to change colors in a page, Calling a function with parameters.

Task 1: computing an average (8 points)

Write a web page that prompts the user for two numbers and prints their average. You must write the computation of average as a function average that takes two numbers and returns their average.

Task 2: Changing the background of a page (10 points).

Write a function that takes a color and changes the background of the entire page to that color. Note that in our examples the <body> tag has an id thepage.

Add two buttons to the page (each in its own form): one to set the page background to any color, the other one to restore it back to white. Both buuttons should call the same function, just with different colors.

At the end of the lab

This page is a part of CSci 1001 course web site.

The views and opinions expressed in this page are strictly those of the page author. The contents of this page have not been reviewed or approved by the University of Minnesota.