Skip to content

Instantly share code, notes, and snippets.

@JLevstein
Created September 27, 2013 14:52
Show Gist options
  • Save JLevstein/6729849 to your computer and use it in GitHub Desktop.
Save JLevstein/6729849 to your computer and use it in GitHub Desktop.
var sidekicks = [
{ name: "Robin", hero: "Batman" },
{ name: "Supergirl", hero: "Superman" },
{ name: "Oracle", hero: "Batman" },
{ name: "Krypto", hero: "Superman" }
];
var batKicks = sidekicks.filter(function (el) {
return (el.hero === "Batman");
});
// Outputs: [
// { name: "Robin", hero: "Batman" },
// { name: "Oracle", hero: "Batman" }
// ]
console.log(batKicks);
var superKicks = sidekicks.filter(function (el) {
return (el.hero === "Superman");
});
// Outputs: [
// { name: "Supergirl", hero: "Superman" },
// { name: "Krypto", hero: "Superman" }
// ]
console.log(superKicks);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment