You are here

Mathematical Thinking through Web Programming - Programming in Javascript

Author(s): 
Dennis DeTurck

Phase III. Beginning to program in Javascript

By Phase III, the students are ready to begin to program, more or less as they had begun in Phase IB to write webpages. In particular, students learned how to make buttons in HTML and to use short Javascript statements to make the buttons active.

The first part of this activity involves modifying an already-existing program, just as with the HTML tables at the beginning of the semester. In particular, students take a very simple page that has only one button (to add two numbers together), and modify it to make a "four-function calculator." The students experience and learn to deal with syntax and other errors, but almost all of them are able to complete this part on their own.

The second half of Phase III is more challenging. Students are required to generate a working program almost "from scratch". We begin with a general discussion of algorithms, in which we review all the games the students played earlier in the semester. We pay special attention to the level of specificity that will be required to communicate our intentions to the computer via a programming language -- any programming language!.

The first programming project that we undertake together is to calculate which day of the year a specific date falls on (e.g., February 5 is the 36th day of the year). The Javascript webpage helps students get started with this one. Subsequent assignments are to calculate and display the number of days between two dates, or (more challenging!) the day of the week of a given date. In this phase, since the problems are chosen to have specific, concise answers, the programming for the output is fairly simple. In fact, we limit the output of the programs in this stage to simple "alert boxes" in which the answer is reported.

A student project based on this much of the programming experience, together with the exponential function unit of the course, is the Carbon-14 dating calculator. For the group of students who did it, this was a fairly ambitious undertaking, and they had to learn a little about the "Math" object in Javascript -- enough to use the exponential, logarithm and rounding functions.

Dennis DeTurck, "Mathematical Thinking through Web Programming - Programming in Javascript," Loci (October 2004)

JOMA

Journal of Online Mathematics and its Applications

Dummy View - NOT TO BE DELETED