Solución
solution.tsTypeScript
export function formatValue(value: string | number): string | number {
// Usa typeof para distinguir string de number
if (typeof value === "string") {
return value.toUpperCase();
} else if (typeof value === "number") {
return value * 2;
}
return value;
}
console.log(formatValue("hola"));
console.log(formatValue(5));0respuestas