src/classes/TripEntity.js
// Creates a Train object from the data in a TrainEntity object
Creates a Train object from the data in a TrainEntity object
Creates a Train object from the data in a TrainEntity object
createTrainOrFindTrainIn(trainsArray) {
    try {
      const trip = this.trip
      let trainObject = trainsArray.filter(i => i.id === trip.tripId)[0];
      if (!trainObject) {
        trainObject = new Train(trip.tripId, this);
      } else {
        trainObject.mostRecentTripEntity = this;
      }
      return trainObject;
    } catch(error) {
      console.log(`Error parsing train at index ${this.index} update:\n`, error)
      return null;
    }
  }
createTrainOrFindTrainIn ( trainsArray ) { try { const trip = this . trip let trainObject = trainsArray . filter ( i => i . id === trip . tripId ) [ 0 ] ; if ( ! trainObject ) { trainObject = new Train ( trip . tripId , this ) ; } else { trainObject . mostRecentTripEntity = this ; } return trainObject ; } catch ( error ) { console . log ( ` ${ this . index } \n ` , error ) return null ; } }
Creates a Train object from the data in a TrainEntity object
Creates a Train object from the data in a TrainEntity object
// Find or create Train object