Solución
solution.tsTypeScript
interface Product {
name: string;
price: number;
currency: string;
discount?: number;
}
export function formatPriceTag( { name, price, currency, discount = 0 }: Product ): string {
// Desestructura el objeto en los parámetros de la función y calcula el precio final
const total = price * ( 1 - discount / 100 );
return `${name}: ${currency}${total.toFixed(2)}`;
}0respuestas