Get Programming with JavaScript - Listing 8.01
Listing 8.01 - Creating arrays
JS Bin
var scores;
var names;
scores = [ 3, 1, 8, 2 ];
names = [ "Kandra", "Dax", "Blinky" ];
console.log(scores);
console.log(names);
Further Adventures
Listing 8.01 - Creating arrays - Task 1
- Add an extra element to each array.
var scores;
var names;
scores = [ 3, 1, 8, 2, 200 ];
names = [ "Kandra", "Dax", "Blinky", "Jahver" ];
console.log(scores);
console.log(names);
Listing 8.01 - Creating arrays - Tasks 2, 3 & 4
- Declare a third variable, akaScores.
- Assign the scores array to akaScores.
- Log akaScores to the console.
var scores;
var names;
var akaScores; // declare
scores = [ 3, 1, 8, 2, 200 ];
names = [ "Kandra", "Dax", "Blinky", "Jahver" ];
akaScores = scores; // assign
console.log(scores);
console.log(names);
console.log(akaScores); // log