Solución
solution.tsTypeScript
function defaultsObject(
target: Record<string, unknown>,
defaults: Record<string, unknown>
): Record<string, unknown> {
for (const key in defaults) {
if (Object.prototype.hasOwnProperty.call(defaults, key)) {
if (!Object.prototype.hasOwnProperty.call(target, key)) {
target[key] = defaults[key];
}
}
}
return target;
}
// No modificar: necesario para evaluar el resultado.
export { defaultsObject };0respuestas