Currently, I am in the process of sifting through an Array that contains nested arrays.
To handle this task, I utilized computed
and crafted a function called filteredEgg()
. However, I seem to be overlooking something, as I'm only returning the main array after filtering for the egg
element within each sub-array. Following that, I created a concise function to fetch the name
from the egg
array.
HTML
<p v-for="egg in filterEgg(digilist)">{{ egg }}</p>
JS
const app = Vue.createApp({
data() {
return {
digilist: [{
egg: [
{
id: "blue",
eggtype: "blue",
name: "Punimon",
},
...
],
baby: [
...
]
}]
}
},
computed: {
filteredEgg(digilist) {
return this.digilist.filter((egg) => {
return egg.name
})
}
},
})
My end goal is to organize creatures based on their evolutionary stage. The filtering function aims to match all evolutions that correspond to specific creatures. For instance, eggtype:"blue"
is linked to name:"Punimon",
, providing a basic example of how creatures are connected through evolution.
The complete database I've developed is too extensive to include here, but you can view it by visiting this link - https://github.com/SheldonAldridge/Digimon-world-divivolution-guides/blob/main/js/Database/digimon-digivolution-database.js