My current item list is displayed below. I am looking to add new items to the list, but if the ID matches an existing entry, I want to update the value of that object.
For example:
segmentValues: [
{
id:1,
value:'Foo'
},
{
id:2,
value: 'Boo'
}
],
segmentValues.push({id: 2, value:'Gogo'});
When adding this new item, it has the same ID as an existing item in the list. Thus, it should replace the value like so:
segmentValues: [
{
id:1,
value:'Foo'
},
{
id:2,
value: 'Gogo'
}
],
How can I achieve this using Vue.js?