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
- Your first program: Output text
- Integer variables (whole numbers, ex -4, 7,
130)
- String variables (text)
- The sandwich simulation
Examples of Parts
View the HTML source to see the Javascript program
- Multiple write commands (output.html)
- None
- Concatenating strings and integers
- Sandwich simulation