# CS383: Lab 5 -- Feb 16

In this lab you will write some simple javascript functions in a single web page (written in you class personal web site). The functions will be be each be started by clicking a button. When each function completes, it will put its result into one or more html elements on the page. The goal for this lab is for you to get used to writing Javascript and more comfortable with using Javascript to dynamically update the page in which the Javascript resides. So, feel free to expand or adapt the suggestions here.

## The functions

Write the following functions.
1. Show the count of the number of times that any button on this page has been hit.
2. Compute the Nth smallest prime number. N should be 3 plus the number of button clicks.
3. The area of a regular pentagon whose sides have length N+2 (again, N is the number of button clicks).
4. Start a countdown timer where the timer counts down from N+2 by an interval given by 10000/(N+2). The idea is that the countdown will always take 10 seconds, just the numer shown will change and the interval between number will change. The timer should change the contents of the button that triggers the timer.

### Sugestions

• Just put formless buttons on the page. Ie buttons that are not in forms. For instance
<button id="ss" type="submit" onclick="function1();">Function 1</button>

• As shown above, specify the onclick action to be the name of one of your functions.
• Create an empty "div"s into which you will put the result of your functions. For instance
<div id="f1result"></div>

Rather than putting everything in divs, maybe use h1, h2, h3 and h4 elements?
• Reminder. You can put Javascript functions and code directly between script tags. For instance this will work
<script>
function ff() { return 6*3; }
</script>

You can also put javascript into a separate file that is specified in the script tag.
<script src="JQ/jquery-1.9.1.min.js"></script>

### What to hand in

Send email to gtowell@brynmawr.edu with a link to the page you created for this lab.