Quick actions

cmd+k|ctrl+k

Navigation

Languages

Challenge: Transit planner

Snippet info

Language

JavaScript

Visibility

public

Author

noemi-techfems

Created

2024-09-06T16:37:39.290151Z

Updated

2024-09-07T12:20:15.882377Z

// Here's the explanation of the challenge -- when you're done reading it,
// click on `main.js` above to get started with the challenge!

// Getting around in a big city is no easy task! With so many options to get 
// from point A to point B, it's easy to get confused. Fortunately, we can use
// code to figure out the best way to travel. 

// ## Description

// In this challenge, you will write a `shortestTrip` function that receives a
// map (object) as an argument. Each key in the map is the name of a mode of
// transit between two places, and its value is an array containing the
// departure and arrival times for that mode of transit, represented as
// strings. The map represents the different modes of transit available
// between two points in a city.

// For example, if the trip can be done by taking the train, a bus, or
// walking, your function could be invoked like:

// shortestTrip({
//   bus: ["09:15", "09:36"],
//   train: ["09:30", "09:42"],
//   walk: ["09:02", "09:40"]
// })

// Your function should return the name of the transit method in which the
// trip takes **the least time to complete** -- _not_ the transit method that
// arrives earlier, but the one in which you spend the least time travelling.

// The list of modes of transit will always contain at least one mode, and
//t he time will always be represented in the `hh:mm` format, using two
// digits for the hours and for the minutes.

// The times will never represent starting and ending on different days,
// meaning the travel times will never cross midnight. The departure time will
// always be earlier than the arrival time. No two trips will take the same
// amount of time.
INFO