Created
April 28, 2018 22:43
-
-
Save claudiainbytes/9b1d1e7aa38fdc4afdf7cf1144aaf2c6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Combining .filter() and .map() | |
* | |
* Using the musicData array, .filter, and .map(): | |
* - filter the musicData array down to just the albums that have | |
* sold over 1,000,000 copies | |
* - on the array returned from .filter(), call .map() | |
* - use .map() to return a string for each item in the array in the | |
* following format: "<artist> is a great performer" | |
* - store the array returned form .map() in a new "popular" variable | |
* | |
* Note: | |
* - do not delete the musicData variable | |
* - do not alter any of the musicData content | |
*/ | |
const musicData = [ | |
{ artist: 'Adele', name: '25', sales: 1731000 }, | |
{ artist: 'Drake', name: 'Views', sales: 1608000 }, | |
{ artist: 'Beyonce', name: 'Lemonade', sales: 1554000 }, | |
{ artist: 'Chris Stapleton', name: 'Traveller', sales: 1085000 }, | |
{ artist: 'Pentatonix', name: 'A Pentatonix Christmas', sales: 904000 }, | |
{ artist: 'Original Broadway Cast Recording', | |
name: 'Hamilton: An American Musical', sales: 820000 }, | |
{ artist: 'Twenty One Pilots', name: 'Blurryface', sales: 738000 }, | |
{ artist: 'Prince', name: 'The Very Best of Prince', sales: 668000 }, | |
{ artist: 'Rihanna', name: 'Anti', sales: 603000 }, | |
{ artist: 'Justin Bieber', name: 'Purpose', sales: 554000 } | |
]; | |
const popular = musicData.filter( musician => musician.sales > 1000000 ).map( musician => `${musician.artist} is a great performer` ); | |
console.log(popular); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment