How to compare data of the two objects?

Hello, I am writing on the website a simple filter
property attributes of goods are recorded in data
Clicking on button want to show the products that correspond to the selected chekbox
From input output in the data id properties
<input data-id="27" data-type="type" type="checkbox" name="type" value="">

get this object, all selected
0: {id: 45, type: "type"}
1: {id: 36, type: "type"}
2: {id: 27, type: "type"}
3: {id: 70, type: "sex"}
4: {id: 72, type: "seson"}


The product also deduce the id properties that he selected,
<div class="product hover_open_add_to_basket" data-type0="20" data-type1="21" data-type2="22" data-type3="23" data-type4="42" data-type5="39" data-price="620">

the problem is that a product can be selected multiple values of the same properties, so in the name of the data attribute had to insert the index.
{type0: 20, type1: 21, type2: 22, type3: 23, 4: 42, ...}
Tell me how to show products for which there is at least one selected type of the chosen one gender and one chosen season, how to compare two object.
March 12th 20 at 08:05
2 answers
March 12th 20 at 08:07
To turn the data into an object (1) and make a filter array of objects, the match properties with the object (1) data.
So I have data in two objects, it can be an example of some sort, never with objects not working - stacey commented on March 12th 20 at 08:10
@stacey, One of the objects necessary to make the array:
let dataArr = [
 { id: 1, money: 15 },
 { id: 2, money: 5 },
 { id: 3, money: 10 },
 { id: 4, money: 20 },
 { id: 5, money: 17 },
]

let r1 = dataArr.filter( v => {
 return v.money > 15
})
console.log( r1 )

let r2 = dataArr.filter( v => {
 return v.id == 5
})
console.log( r2 )

let r3 = dataArr.filter( v => {
 return (v.id > 2 && v.money >= 17)
})
console.log( r3 )
- adolf.Bruen commented on March 12th 20 at 08:13
March 12th 20 at 08:09
If you put in data-type ID list all filters in product, instead of many data-typeN, we can do without the extra checks in the name of the keys in the dataset element with the product.

I sketched out an example https://codepen.io/anon/pen/PypLjB
but in this decision you need to make sure that the list data types do not contain spaces

... the response is described in the method available()

Find more questions by tags JavaScript