Created
June 1, 2017 04:50
-
-
Save bryzettler/e6f3a2090ca5b247328718bc666b3355 to your computer and use it in GitHub Desktop.
This file contains 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
const records = [ | |
{ title: "The Clash", artist: "The Clash", type: "LP", lengthSec: 2220, released: "1977"}, | |
{ title: "Rocket to Russia", artist: "Ramones", type: "LP", lengthSec: 1906, released: "1977"}, | |
{ title: "London Calling", artist: "The Clash", type: "LP", lengthSec: 3903, released: "1979"}, | |
{ title: "Ramones", artist: "Ramones", type: "LP", lengthSec: 1755, released: "1976"}, | |
...etc | |
]; | |
const removeIndexes = [1, 2]; | |
records.reduceRight((acc, item, idx) => { | |
// index exists in removeIndexes | |
// lets remove/filter it out | |
if(removeIndexes.includes(idx)) return acc; | |
// otherwise add it to the final result | |
return [ | |
...acc, | |
record, | |
]; | |
}, []); | |
/* | |
=> [ | |
{ title: "The Clash", artist: "The Clash", type: "LP", lengthSec: 2220, released: "1977"}, | |
{ title: "Ramones", artist: "Ramones", type: "LP", lengthSec: 1755, released: "1976"}, | |
] | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment