Objectives

Chapter 3: Building Arrays and Controlling Flow
    After completing this chapter, the student will be able to:

  • Store data in arrays
  • Use while statements, do/while statements, and for statements to repeatedly execute code<
  • Use continue statements to restart looping statements
  • Use if statements, if/else statements, and switch statements to make decisions
  • Nest one if statement in another
Assignments and Due Dates
Assignments and Due Dates: View
Tutorials

Required Sample Code

Completed sample code from Chapter 03    JS6eTextCode_Chapter03
Download the zip file and extract it.

The sample code prepared specifically for CS2513    CS2513ClassCode_Chapter03

    • Arrays.html
      use of various dataypes in an arrray
    • SwitchStatements.html
      use of various datatypes in a case statement
    • DynamicLists.html
      create lists dynamically, event listener/attach event, parameter passing using anonymous functions
Supplemental Materials
  1. PowerPoint from Text: CS2513GosselinJS_CH03 - View (ppt) | Print (pdf)
Software

Same software as previously indicated.

Chapter Questions and Test Reviews

Chapter Review Questions
Source for quiz and test questions. It is highly recommended that students know the answers.

Chapter 3: Review Questions (.rtf file)
Test 1: Review Sheet

Required Assignments

CSP03 - Arrays and Control Flow: Specifications (Complete, upload to Apollo1, then submit URL in the LMS)
Weekly Quiz: Chapter 3 (Located in the LMS)

Professor's Class Notes and Comments

Read Chapter 3 thoroughly and become familiar with JavaScript syntax

Again many of these concepts should be a refresher from Beginning Programming. When reviewing the information about arrays, keep in mind that in JavaScript, elements of an array may be varying data types. One element may be an integer and another element of the same array may be a string. The sample code, ArrayDeclaration.html, demonstrates this.

P. 148

Arrays are an important concept and will be used throughout the course. Although they are not a major part of this week's assignments, they material will be on the test and it will be used in future assignments.

P. 163

While Loops are discussed. Keep in mind that these are pre-test loops - condition is tested before execution of the commands. The commands may or may not be executed based on the results of the test.

P. 169

Do/While loops, the commands will always be executed at least one time because the test is at the end of the loop. This structure is known as a post-test loop.

P. 206

Notice that the event listener/attach event code uses the click/onclick events. If it is used in conjunction with a "submit" button, it might be logical to think about the event being submit instead of click/onclick. Experiment with this. I have found that if a new page is to be displayed using document.write (as in this week's assignment), it will work as desired in FireFox. However, in Chrome and Safari it will display the new page for a flash instant (better watch really close or you will miss it!!) and then it returns to the original forms page. Also, in these cases, the input type be "button" as opposed to "submit".

Reminder

If youi have not done so, be sure to check out the sample code (see above) created specifically for CS2513. It could help furhter your knowledge as well as make the assignments a little easier. There is an important example of passing parameters using event listeners and anonymous functions. Be sure to check it out

In the DynamicLists.html sample web page, the code document.close() is included. This is not in the text. However, if that code is not included, the tab icon in FireFox will continue to indicate that the page is still loading. Including this code, stop the process but does not change the web page. Be sure to check it out.

Summary: This will be the last chapter for which the summary will be included. Students should be very familiar with the process by this point in time.

Have you?

  • Read the entire weekly materials page
  • Read the professor's notes
  • Completed the required readings
  • Made the modifications to the Fan Trick Fine Art Photography website using the chapter instructions to modify the starter files (using the sample code download as needed).
  • Answered the Chapter 3 Review Questions
  • Used the supplemental materials you might have found helpful
  • Taken the chapter quiz
  • Completed the required assignments