I'm using an array.find below and it works to return BreakdownPalletID when the itemScan value is found in the array. If it's not found my application returns a 'Cannot read property breakdownPalletID of undefined'. The user enters the itemScan so I want to have this behavoir and then to signify to the user that that string was not found. How can I handle this undefined error?
let palletID = this.transferPalletBreakdownData.Sku.find(x => x.sku == this.itemScan).breakdownPalletID
console.log(palletID);