Building a project in VueJS with data coming from an api (using axios): I have a list of projects with props (year, location, etc) and tags (house, park, etc). I have made this filter to toggle the sort by prop:
sortby(data) {
// data = {prop: "year", tag: "house"}
//
if (data.prop === "year") {
this.projects.sort((a, b) => (a[data.prop] < b[data.prop] ? 1 : -1));
} else {
this.projects.sort((a, b) => (a[data.prop] < b[data.prop] ? -1 : 1));
}
},
but after the sort I would like to only show the objects that have tag === "house".
any ideas? thanks!
.filter(({tag}) => tag === 'house')?