I have a method on @change which recieve these values.
changeAttr(id, key, value) {
const selections = [];
},
id could be any number, key could be: color, size, sex, etc..., value could be: red, 8, female, etc. In the first reception the values can be for example:
id = 3,key = "color",value = "red"and they change when the user select another option. For example:id = 3,key = "sex",value = "female"orid = 5,key = "size",value = "50"...etc
I want to dynamically fill an array of objects with the values this way for example.
selections = [{
"3": {
"color": "red",
"sex": "male",
"size": "40"
},
{
"5": {
"color": "black",
"sex": "female",
"size": "36"
},
{
"8":{
"color": "black",
"sex": "female",
"size": "36"
...
},
...
}];
I want to overwrite the values if the key already exists for the same id. If it does not exist, it must be added for its id.
I hope I have explained clearly. Thank you very much for your time