You need to sign in to do that
Don't have an account?

Splice method gives error.
In the below code I am trying to remove the element from the array, the splice method is failing for some reason.
// this.productId = {
// [
// {
// "Id": "a001700000802ZJAAY",
// "Name": "Medium Pizza",
// "Price__c": 9
// },
// {
// "Id": "a0017000007ztMUAAY",
// "Name": "Large Pizza",
// "Price__c": 10
// }
// ]
// }
handleDeleteSelected(event){
console.log('handle Delete', JSON.stringify(event.detail))
// handle Delete {"Id":"a001700000802ZJAAY","Name":"Medium Pizza","Price__c":9}
var del = event.detail.Id
const productIndex = this.productId.findIndex(e => e.Id === del);
const productupdate = this.productId;
// delete the Medium Pizza from the productupdate array
productupdate.splice(productIndex, 1)
console.log('productIndex', productIndex)
console.log(productupdate)
}
// this.productId = {
// [
// {
// "Id": "a001700000802ZJAAY",
// "Name": "Medium Pizza",
// "Price__c": 9
// },
// {
// "Id": "a0017000007ztMUAAY",
// "Name": "Large Pizza",
// "Price__c": 10
// }
// ]
// }
handleDeleteSelected(event){
console.log('handle Delete', JSON.stringify(event.detail))
// handle Delete {"Id":"a001700000802ZJAAY","Name":"Medium Pizza","Price__c":9}
var del = event.detail.Id
const productIndex = this.productId.findIndex(e => e.Id === del);
const productupdate = this.productId;
// delete the Medium Pizza from the productupdate array
productupdate.splice(productIndex, 1)
console.log('productIndex', productIndex)
console.log(productupdate)
}
productupdate.splice(productIndex, 1)