Tutorial: Javascript Part 2 - Prompts, Selection, & Loops

Goals: 1) To learn a very popular scripting language for client-side Web programming. 2) To learn the basic programming concepts and techniques fundamental to all programming languages.

I. Learning the basics of Javascript

Read Chapter 8 in our textbook, or go to http://www.w3schools.com/js and work through the following lessons, examining examples, reading the material, and experimenting with the code yourself:

  1. JS If...Else
  2. JS Operators
  3. JS Popup Boxes
  4. JS For Loop
  5. JS While Loop

Note: There are many Javascript resources on the Web. http://www.webmonkey.com/programming/javascript/ is another good tutorial. Google "Learn Javascript" to find more.

II. Learn by example - perhaps the most important exercise!

Open the following html/javascript example files, and view their source code. The code includes comments that explain what each example teaches.

  1. js6 prompt
  2. js7 prompts2
  3. Calculate Miles per Gallon (MPG)
  4. js8 if-else if-else
  5. js9 for
  6. Calculate Academic Progress
  7. Javascript with HTML Form - "Flip A Coin"

IV Create your own javascript program

Complete the remainder of the assignment.