unc comp 110 fall 07.

Recitation: My first program


Purpose of recitation: Write your first program and practice using variables. Variables were covered in Wed's lecture. Your first programs will be a simulation of the sandwich example. You will make a peanut butter and jelly sandwich. The sandwich will be output as text.

Your program is written in the Javascript Programming language. It will be run in your web browser. In this recitation, your program will output simple web pages. You could produce the same output with a regular HTML file. This output is static. The key to the Javascript program is that YOUR program is creating the web page. With different input, your program can produce different results.

In the notes you are given program snippets (lines of code exactly as they should appear). I recommend you type the example program snippets. It will help you practice and think about the program you are writing. Of course, you could copy and paste the program snippets.


Work through these parts. As you work, post your questions here.

Parts

  1. Your first program: Output text
  2. Integer variables (whole numbers, ex -4, 7, 130)
  3. String variables (text)
  4. The sandwich simulation
     

Examples of Parts

View the HTML source to see the Javascript program
  1. Multiple write commands (output.html)
  2. None
  3. Concatenating strings and integers
  4. Sandwich simulation