Skip to content

Instantly share code, notes, and snippets.

@jpetto
Created August 26, 2012 20:25
Show Gist options
  • Save jpetto/3483373 to your computer and use it in GitHub Desktop.
Save jpetto/3483373 to your computer and use it in GitHub Desktop.
JavaScript array methods - 1
var coffees = ['Ethiopia', 'Rwanda', 'Burundia', 'Kenya', 'Tanzania'];
var coffee_string = coffees.join(", ");
console.log(coffee_string);
// removes the last element in the array and stores it in last
var last = coffees.pop();
console.log(last);
console.log(coffees);
// adds a new coffee to the end of the array
// equivalent to coffees[coffees.length] = "Zambia";
coffees.push("Zambia");
console.log(coffees);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment