Within my code, there is an array called addRows
that holds a collection of objects.
These objects are dynamically added when the user clicks on a specific button.
Once added, these objects are then pushed into the addRows
array for the user to fill in.
Each object within this array contains various input values like price and quantity.
The challenge I am facing is updating the price when the quantity changes. The issue arises when the new value overlaps with existing values, causing the returned item to be empty.
This occurs because the new value has already been added to the old values array.
In the image displayed, the third value is the same as the first, resulting in the array returning an empty value for the third item.
I have attempted using foreach, for loops, and maps, but unfortunately, I continue to encounter the same problem.
computed: {
originalDistValue(a , b) {
return this.addRows.map(i => {
return i.dist
})
}
}, // close computed
watch: {
originalDistValue(a , b) {
let newVal = a.filter( obj => {
return b.indexOf(obj) == -1;
})
let element = this.addRows.filter( i => {
return i.dist == newVal;
})
deep: true
console.log(newVal)
for(let i in element) {
element[i].cit = 1;
}
}
}