Skip to content

Instantly share code, notes, and snippets.

@goodbedford
Last active April 2, 2016 03:41
Show Gist options
  • Save goodbedford/43aeee08a94a69d62c2b6b45c67b67c5 to your computer and use it in GitHub Desktop.
Save goodbedford/43aeee08a94a69d62c2b6b45c67b67c5 to your computer and use it in GitHub Desktop.
var rsvps = ["julie", "greg", "jess", "nicole", "kenn", "al", "angelina", "boo balm"];
console.log("rsvps:", rsvps);
// we need to add Dave to the end of party list
rsvps.push("dave");
console.log("after adding dave:", rsvps);
// julie can't make it, lets take her off the top
rsvps.shift();
console.log("after shifting julie:", rsvps);
// moms comming so put her first on the list
rsvps.unshift("mom");
console.log("after unshifting mom:", rsvps);
// dave can't make it anymore, take him off the end
rsvps.pop("dave");
console.log("after popping dave off:", rsvps);
// remember array index starts at zero
rsvps = ["tracy", "bedford", "christina", "nicole", "lisa", "mark", "aaron", "marina"];
console.log("new party rsvps", rsvps);
// make a new list for the guys only after party using someArray[index] and push
var guys = [];
var otherGuys = [];
guys.push( rsvps[1]); //bedford
guys.push( rsvps[5]); //mark
guys.push( rsvps[6]); //aaron
otherGuys.push(rsvps[1],rsvps[5],rsvps[6]);
console.log("guys after-party", guys);
console.log("other guys after-party", otherGuys);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment