Paracetamol.js馃拪| #170: Explica este c贸digo JavaScript

Cristian Fernando - Jul 19 '22 - - Dev Community

Explica este c贸digo JavaScript

Dificultad: Intermedio

const perro = {
  id:1,
  color:"negro",
  cola: false
}

const DEFAULT_OBJ = {
  id: "sin id",
  color: "default",
  nombre: "sin nombre",
  cola: "-"
}

const getPerro = (obj) => {
  return {
    ...DEFAULT_OBJ,
    ...obj
  }
}

console.log(getPerro(perro))
Enter fullscreen mode Exit fullscreen mode

A.

{
  id:1,
  color: "negro",
  cola: false
}
Enter fullscreen mode Exit fullscreen mode

B.

{
  id:1,
  color: "negro",
  nombre: "Boby",
  cola: false
}
Enter fullscreen mode Exit fullscreen mode

C.

{
  id:1,
  color: "negro",
  nombre: "sin nombre",
  cola: false
}
Enter fullscreen mode Exit fullscreen mode

D. Ninguno de los anteriores

Respuesta en el primer comentario.


. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .