say I have list of objects retrieved from database and I'm iterating them through foreach loop in script bloc
export default {
props: {
guests: {
type: Object,
default: null,
},
...
},
computed: {
myGuests() {
this.guests.forEach(guest => {
// the if guest.age > than 18 condition should be here
const myGuests = JSON.parse(JSON.stringify(guest));
// body of my method
});
return ...;
},
},
I want to make a condition on it so if the age is greater than 18 I store them on another object, then when I call the method from template bloc the directive v-for should go through those elements (i.e guests whose age is greater than 18 (instead of going through all of guests with their different ages))
v-for="(guest, g) in myGuests" //call for the new created object whose age property is > 18
:key="g"
...