Answer the question
In order to leave comments, you need to log in
How to filter an array by another array?
I'm trying to create a filtering of an array of objects by the params array property, which contains string values.
includes takes the first string value, but how to pass an array?
List = [
{
"id":12,
"name": "Фламинго",
"price": 1200,
"view":[""],
"params":["птица","окно"]
},
{
"id":13,
"name": "Семейная",
"price": 1800,
"view":[""],
"params":["камин","качель","окно"]
},
...
]
const mapStateToProps = state => (
{
list:state.list.filter(item => item.params.some(i=> i.includes(["качель","окно"]) ) ),
}
);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question