Code Lab

Modo entrevista. Temporizador de 3 min, sin pistas y sin autocompletado

First object

FácilObjects3 min

Write a function editUser(user) that gets a user object.

Add the property surname with the value 'Smith', change name to 'Pete' and delete the property age. Leave the other properties as they are. Return the same object.

Ejemplos

editUser({ name: 'John', age: 30 })

Devuelve { name: 'Pete', surname: 'Smith' }

editUser({ name: 'Ann', city: 'Oslo' })

Devuelve { name: 'Pete', city: 'Oslo', surname: 'Smith' }

The property `city` stays.

Fuente

Cargando el editor…
  1. EntradaeditUser({ name: 'John', age: 30 })
    Esperado{ name: 'Pete', surname: 'Smith' }
  2. EntradaeditUser({ name: 'Ann', city: 'Oslo' })
    Esperado{ name: 'Pete', city: 'Oslo', surname: 'Smith' }
  3. Returns the same object

Las pruebas ocultas se ejecutan al enviar