Solución
solution.tsTypeScript
export function createServer(options: { host?: string; port?: number }): string {
const { host = 'localhost', port = 3000 } = options;
return `${host}:${port}`;
}
1respuestas
export function createServer(options: { host?: string; port?: number }): string {
const { host = 'localhost', port = 3000 } = options;
return `${host}:${port}`;
}
La desestructuración está muy bien hecha, a pesar de que el enunciado indica usar la desestructuración en el parámetro.
Recuerda ser amable. Estás comentando la solución de otra persona. Comparte tu perspectiva de forma constructiva y respetuosa.