Definition
Set of data represented by a single variable name
Index
the position or location within the array
Element/Value
the data stored within the position of the array
Array Literal
most common way to create an array
declares a variable and specifies array as content
Array Object
the syntax for declaring a new array instance
The map, reduce, filter methods allow for a variety of ways to work with the data contained in the list.
Sequence ✦ Selection ✦ Looping
if statements ⛄ if/else statements ⛄ switch statements
int numOne = 2; int numTwo = 5;
if(numOne >= numTwo){
console.log("2 is greater than 5");
}else{
console.log("2 is not greater than 5");
}
Dual-alternative selection structure
var numOne = 2; var numTwo = 5;
if(numOne <= numTwo){
console.log("5 is greater than 2");
}
Single-alternative selection structure
Initial loop control variable initialized before entering loop
Loop control variable tested
Body of loop must alter value of loop control variable
var initialValue = 0; //Initial Value for Control variable
var endValue = 4;
var topics = [ "Structures", "Decision Making", "Looping", "Arrays"];
while(initialValue < endValue){ //Control variable tested
console.log("Week " + (initialValue + 1) + " is " + topics[initialValue]);
initialValue++; //Control Variable altered
}
console.log("Finished");
Step 1
Observe the diagram above and declare for the data you will use in program. Declare an array that holds the month names.
Step 2
Think through and apply the correct structures to fulfill the requirements of the program.
Step 3
Code the program and output the month along with the correct number of days for each month.