Is there a way to replace the if else statement in the function using a Ternary operator in JavaScript?
private getProductName(productType: string): string {
let productName = 'Product not found';
this.deal.packages.find(p => p.isSelected).dealProducts.find(dp => (dp.children.length > 0 && dp.children[0].product.productTypeCode == productType)) ?
productName = this.deal.packages.find(p => p.isSelected).dealProducts.find(dp => (dp.children.length > 0 && dp.children[0].product.productTypeCode == productType)).children[0].product.name :
this.deal.packages.find(p => p.isSelected).dealProducts.find(dp => (dp.children.length === 0 && dp.product.productTypeCode === productType)) ?
productName = this.deal.packages.find(p => p.isSelected).dealProducts.find(dp => (dp.children.length === 0 && dp.product.productTypeCode === productType)).product.name :
null;
return productName;
}