Created
July 22, 2022 11:51
-
-
Save zloader/87cfaa20835cd5c4f62eff0bb2bf8403 to your computer and use it in GitHub Desktop.
Remove characters with duplicated power color from collection
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 https = require('https'); | |
https.get( | |
"https://my.api.mockaroo.com/mpq-cards.json?key=a65ab360", | |
(r) => { | |
let content = "" | |
r.on("data", (chunk) => { content += chunk; }); | |
r.on("end", () => { | |
try { | |
const raw = JSON.parse(content); | |
const filtered = raw.filter(i => i.powers.length === new Set(i.powers.map(p => p.color)).size); | |
console.log(`Source Characters Count: ${raw.length}`) | |
console.log(`Filtered Characters Count: ${filtered.length}`) | |
} catch (e) { | |
console.error(e.message); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment