Code Lab

Mode entretien. Minuteur de 3 min, sans indices ni autocomplétion

First object

FacileObjects3 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.

Exemples

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

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

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

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

The property `city` stays.

Source

Chargement de l'éditeur...
  1. EntréeeditUser({ name: 'John', age: 30 })
    Attendu{ name: 'Pete', surname: 'Smith' }
  2. EntréeeditUser({ name: 'Ann', city: 'Oslo' })
    Attendu{ name: 'Pete', city: 'Oslo', surname: 'Smith' }
  3. Returns the same object

Les tests cachés se lancent à la soumission