Code Lab

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

Merge the route

FácilObjects5 min

The data of a train route is kept in objects. Write two functions.

extendRouteInformation(route, more) returns a new object with all properties of route and more.

separateTimeOfArrival(route) returns an array of two elements: the value of timeOfArrival, then a new object with the other properties of route.

Do not change the objects passed to the functions.

Ejemplos

extendRouteInformation({ from: 'Paris', to: 'Lyon' }, { length: '100' })

Devuelve { from: 'Paris', to: 'Lyon', length: '100' }

separateTimeOfArrival({ from: 'Paris', to: 'Lyon', timeOfArrival: '10:10' })

Devuelve [ '10:10', { from: 'Paris', to: 'Lyon' } ]

Fuente

Cargando el editor…
  1. EntradaextendRouteInformation({ from: 'Paris', to: 'Lyon' }, { length: '100', speed: '50' })
    Esperado{ from: 'Paris', to: 'Lyon', length: '100', speed: '50' }
  2. separateTimeOfArrival takes out the arrival time
  3. extendRouteInformation does not change route

Las pruebas ocultas se ejecutan al enviar