code: function combineSearch(tp1, tp2) {
    return tp1.map(travelPlan => {
      let arrival = new Date(travelPlan.legs[travelPlan.legs.length - 1].arrival)
      let bestWaitTime = Infinity
      let bestTravelPlan2 = tp2[0]
      // Find the most appropriate corresponding second travel plan.
      for (let i = 0; i < tp2.length; i++) {
        let travelPlan2 = tp2[i]
        let departure = new Date(travelPlan2.legs[0].departure)
        let waitTime = departure - arrival
        if (waitTime > 0) {
          if (waitTime < bestWaitTime) {
            bestWaitTime = waitTime
            bestTravelPlan2 = travelPlan2
          }
        }
      }
      return {
        fares: combineFares(travelPlan.fares, bestTravelPlan2.fares),
        legs: travelPlan.legs.slice().concat(bestTravelPlan2.legs.slice()),
      }
    })
  }
docs: Take two travel plans, combine them so that one is the first part of the journey of the other. We assume that the last station of the first travel plans is the first station of the second travel plans.