ArraysI - Array Collection of values that can be treated as a unit or individually var a = new Array(4 You can visualize an array as a set of

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
ANNOUNCEMENTS Check class announcements daily You must implement programming projects by yourself Web Fonts by Google: http://code.google.com/apis/webfonts/ 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 FOR LOOP Iteration statement General form for (initialize; test; expression) statement basically equivalent to Initialize while (test) { statement expression } If more than one statement use { } Semicolons are required Beware of infinite loop if semicolon after parenthesis Example: ForLoop.html Example: ForLoopVariations.html
Background image of page 2
3 NESTED LOOPS You can combine if, while and do while statements in several ways You can have several nested if statements You can have if statements within while statements You can have while statements within if Example: NestedLoops.html Example: MultiplicationTable.html
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4 ONE-DIMENSIONAL ARRAYS Problem You need to keep track of the scores of students in a class Declaring and handling 50 variables is not an easy task Arrays come to the rescue
Background image of page 4
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 6
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Array Collection of values that can be treated as a unit or individually var a = new Array(4) You can visualize an array as a set of variables one after another Indexing We access an element using [ ] First element associated with index 0 (e.g., a[0]) An element of an array can be of any type and an array can hold different types of elements The length property represents the length of the array (e.g., a.length) We can print the contents of an array by using alert Example: ArrayEx.html 5 DEFINITION OF ONE-DIMENSIONAL ARRAYS Via array literal comma separated list of elements within square brackets var a = [2, 3, 5]; var b = ; // empty array Specified in the Array constructor var c = new Array(); var e = new Array(4); // defines array of size 4 6 What is Top-Down Design? Let’s go over an example Video Store Software Bottom-Up Design TOP-DOWN DESIGN...
View Full Document

This note was uploaded on 01/12/2012 for the course CMSC 122 taught by Professor Staff during the Fall '08 term at Maryland.

Page1 / 6

ArraysI - Array Collection of values that can be treated as a unit or individually var a = new Array(4 You can visualize an array as a set of

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online