Answer the question
In order to leave comments, you need to log in
How to make complex filters in js?
I am writing a project in vue.
With js with grief in half, but I can do something without jquery.
Interested in how to repeat such filters as here on the site stomportal.kz
As I understand it:
There is an array in which posts are stored by objects ([{title:'post1'},{title:'post2'}])
Each post has a properties object
And let 's say it looks like this www.jsoneditoronline.org/?id=a9bb41e2e23b75260c13e...
[
{
"title": "post1",
"properties": {
"date": "date1",
"time": "time1",
"services": [
"sevice1", "service2"
]
}
},
{
"title": "post2",
"properties": {
"date": "date2",
"time": "time2",
"services": [
"sevice4", "service2"
]
}
},
{
"title": "post3",
"properties": {
"date": "date1",
"time": "time3",
"services": [
"sevice1", "service3"
]
}
},
{
"title": "post4",
"properties": {
"date": "date3",
"time": "time2",
"services": [
"sevice3", "service4"
]
}
}
]
{
"date": "date1",
"time": "time2",
"services": [
"sevice4"
]
}
Answer the question
In order to leave comments, you need to log in
data.filter(item=>(
item.properties.date === "date1" &&
item.properties.time === "time2" &&
item.properties.services.indexOf("sevice4") !== -1
))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question