'Return results for results which include the variable in the array in VueJS/JS
I have a issue whereby my results will return if I match one of the months in my array ie. 'April'. The issue I have is that my result wont return if the startdate output has multiple months i.e (Jan, Feb, April)
Can anyone help? I hope I have provided enough info below.
<h3 class="pt-4">Start month</h3>
<ul
v-for="startdate in uniquestartdate"
:key="startdate"
class="d-inline"
>
<li>
<label class="pr-2">{{ startdate }}</label>
<input type="checkbox" v-model="startdates" :value="startdate" />
</li>
</ul>
computed: {
dataFilters() {
this.updateURL();
const filteredResults = this.results.filter((a) => {
if (
this.startdates.length &&
!this.startdates.includes(a.startdate)
)
return false;
return true;
});
return filteredResults;
},
}
methods: {
const startdate = this.results
.filter((result) => result && result.startdate)
.map((item) => item.startdate)
.filter((startdate, i, arr) => arr.indexOf(startdate) === i);
// Split multiple levels in strings and store in an array
let startdate = [];
startdate.forEach((item) => {
const splitArr = item.split(", ");
startdate = startdate.concat(splitArr).sort();
});
// Filter again for unique
this.uniquestartdate = startdate.filter(
(startdate, i, arr) => arr.indexOf(startdate) === i
);
this.results.forEach((result) => {
console.log(result.startdate);
});
}
** The image below shows the output for 'this.results.forEach((result) => {
console.log(result.startdate);'**
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

