Skip to content

Instantly share code, notes, and snippets.

@JoaoCnh
Created February 14, 2018 11:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save JoaoCnh/e8fdd2543c747907363eff4550ccbda1 to your computer and use it in GitHub Desktop.
Save JoaoCnh/e8fdd2543c747907363eff4550ccbda1 to your computer and use it in GitHub Desktop.
Filter example 3
// using the songs array from previous examples
var mastodonSongs = songs.filter(function (song) {
return song.artist.toLowerCase() === "mastodon";
});
// ES6
const mastodonSongs = songs.filter(song => {
return song.artist.toLowerCase() === "mastodon";
});
console.log(mastodonSongs);
// [{
// id: 1,
// name: "Curl of the Burl",
// artist: "Mastodon",
// },
// {
// id: 2,
// name: "Oblivion",
// artist: "Mastodon",
// }]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment