I’ve got an object having this form:
const obj = {
abc: "Moon",
def: "Earth",
asd: "Sun",
dmg: "Venus",
xyz: "Mars",
tuv: "Jupiter"
};
And an array with this form:
const arr = ["abc", "def", "tuv"];
I want to filter obj based on the values given in arr. That means, is there a way, probably using the filter method, to turn obj into this:
const newObj = {
abc: "Moon",
def: "Earth",
tuv: "Jupiter"
};