title: Find prev and next element from the json array of objects using current eventid using JS
body: <p>Working: To display the data in current id from Json:</p>
  
  <pre><code>var _getEventById = function(eventId) {
  
          var __findEvent = function(event) {
              return event.id === eventId;
          };
  
          return _.find(data.meeting.events, __findEvent);
      };
  </code></pre>
  
  <p>I want to find the prev and next events.number using the current event ID. The below code doesn't work. it is written inside the model.</p>
  
  <pre><code>  var _getNextEvent = function(eventNumber) {
    var nextEventNumber = data.meeting.events.number += eventNumber ;
    var nextEvent = _.find(event, function(event) {
      return event.number === nextEventNumber;
    });
  
    return nextEvent.id;
  };
  
  
  var _getPrevEvent = function(eventNumber) {
    var prevEventNumber = data.meeting.events.number -= eventNumber ;
  
    var prevEvent = _.find(event, function(event) {
      return event.number === prevEventNumber;
    });
  
    return prevEvent.id;
  };
  </code></pre>
  
  <p>What I tried is to pass the current events.id and find the events.number using Lodash and add one to find the next events number. with the Next event number to return its next events.id. (subtract to find the prev event id)</p>
  
  <pre><code>JSON: "meeting": {
        "id": "SING_74",
        "name": "Singapore Racing",
        "runDate": "2017-10-04",
        "meetingNumber": 12,
        "closeDate": "2017-10-04",
        "open": true,
        "venue": "Overseas",
        "currentRaceId": "SING_74_2",
        "code": "RACE",
        **"events": [**
          {
            **"id": "SING_74_1",**
            **"number": 1,**
            "open": false,
            "status": "Closed"
          },
          {
            "id": "SING_74_3",
            "number": 3,
            "open": true,
            "status": "Open"
          },
          {
            "id": "SING_74_4",
            "number": 4,
            "open": true,
            "status": "Open"
          },
          {
            "id": "SING_74_5",
            "number": 5,
            "open": true,
            "status": "Open"
          },
  </code></pre>
  
  <p>Achieve: what I am trying to achieve in angular is when user swipe on the Racing/events. it should identify ng-swipe-left and ng-swipe-right and update the data with the nexteventid or preveventid.</p>
  
  <p>If you share any inputs or examples are much appreciated.</p>