I'm trying to sort this JavaScript object so only certain rows are returned, the object:
const baseHeroes = [
{ name: "Batman", powers: ["Strength", "Intelligence"] },
{ name: "Superman", powers: ["Strength", "Flying"] },
{ name: "Spiderman", powers: ["Spider Sense", "Webs"] },
{ name: "The Flash", powers: ["Speed"] },
{ name: "Captain America", powers: ["Strength", "Shield"] },
];
I want to return only the rows that have the power "Strength" in the powers section, but to return the full row with all data, so I'd want to have this when finished:
const strongHeroes = [
{ name: "Batman", powers: ["Strength", "Intelligence"] },
{ name: "Superman", powers: ["Strength", "Flying"] },
{ name: "Captain America", powers: ["Strength", "Shield"] },
];
Any help would be greatly appreciated.
["Strength", "Flying"], contains"Strength"?