Skip to content

Instantly share code, notes, and snippets.

@goodbedford
Last active August 6, 2016 19:46
Show Gist options
  • Save goodbedford/559852cd81818900742d4875a71c5597 to your computer and use it in GitHub Desktop.
Save goodbedford/559852cd81818900742d4875a71c5597 to your computer and use it in GitHub Desktop.
// remember array index starts at zero
var rsvps = ["tracy", "bedford", "christina", "nicole", "lisa", "mark", "aaron", "marina"];
var girls = [];
console.log("\nnew party rsvps", rsvps);
// Pop Quiz: Make a list of girls for the after party using someArray[index] and push
// ------ add code below this line--------------------
girls.push( rsvps[0], rsvps[2], rsvps[3], rsvps[4], rsvps[7]);
//------ add code above this line --------------
console.log("\ngirls after party:", girls);
// Pop Quiz: manipulate the following list
var hats = ["ten-gallon", "fedora", "giants baseball", "warrios knitted", "kango", "sherlock holmes" ];
var beginNumOfHats;;
var giantsHatIndex;
var clownHat = "clown-hat";
var myHat;
// 2a. change beginNumOfHats to number of hats to start
// ------ add code below this line--------------------
beginNumOfHats = hats.length;
//------ add code above this line --------------
console.log("\n# of hats to start:", beginNumOfHats);
// 2b. what index is giants baseball hat
// ------ add code below this line--------------------
giantsHatIndex = 2;
//------ add code above this line -------------------
console.log("\ngiants baseball hat index:", giantsHatIndex);
// 2c.
// 1. take off the ten-gallon hat
// 2. take off the fedora
// 3. add clown-hat to front
// 4. add a type of hat for myhat to the end
// 5. add clown-hat to end
// ------ add code below this line--------------------
myHat = "fluffy hat";
hats.shift();
hats.shift();
hats.unshift(clownHat);
hats.push(myHat);
hats.push(clownHat);
//------ add code above this line -------------------
console.log("\nhats after changes", hats);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment