i have an array that is been already loaded on to view, i need to update a specific object in array
modified_data(){
this.nativeStorage.getItem("modifiedData").then((data)=>{
console.log("modified_data fun", data);
// console.log(this.dailyDays);
var array = this.dailyDays;
for (var i = 0; i < array.length; i++) {
var element = array[i];
// console.log("in aloop",element.day);
if (element.day === data.day) {
console.log("got same da", element);
this.dailyDays.push({
day: data.day,
month: this.currentDate.getMonth(),
year: this.currentDate.getFullYear(),
price: data.price,
brand: data.selectedBrand,
howManyDay: data.selectedDay,
quantity: data.selectedQuantity
});
} else {
}
}
})
}
By using the above code a new object gets added up at the bottom of the array in html,
The array in the view have a date listed if i find the same date then that date should be updated with the new object some one help me
dataobject with all objects inarrayand if you don't find a match, you adddatatoarray, if you do find a match, you need to replace the existing one withdata, correct?