Currently, I am utilizing an array.find function to search for the BreakdownPalletID when the itemScan value matches a SKU in the array. However, if there is no match found, my application throws a 'Cannot read property breakdownPalletID of undefined' error. Since the user inputs the itemScan value, I want to maintain this functionality while also informing the user that the specified string was not located. What approach should I take to manage this undefined error?
let palletID = this.transferPalletBreakdownData.Sku.find(x => x.sku == this.itemScan)?.breakdownPalletID
console.log(palletID);