function pickDetailField (field, arry) {
  return arry.reduce((p, c, i) => {
    if (c.tag === 'dt') {
      if (c.child[0].text === field) {
        if (field === 'Class&nbsp;date/time') {
          p = convertDateStringToDateObj(arry[i + 1].child[0].text);
        } else if (field === 'Room') {
          // This is a list of spans we need to parse through
          if (arry[i + 1].child) {
            p = {
              room    : arry[i + 1].child[0] ? arry[i + 1].child[0].child[0].text : '',
              building: arry[i + 1].child[1] ? arry[i + 1].child[1].child[0].text : '',
              address : arry[i + 1].child[2] ? arry[i + 1].child[2].child[0].text : ''
            };
          } else {
            p = {room: '', building: '', address: ''};
          }

        } else {
          // an element that we need to grab text node from
          p = arry[i + 1].child ? arry[i + 1].child[0].text : '';
        }
      }
    }
    return p;
  }, '');
}
/*
 Look over the dt/dd list and find the data we want
 since a dd is the next element we're getting it with the i+1
 */
Look over the dt/dd list and find the data we want
since a dd is the next element we're getting it with the i+1
Look over the dt / dd list and find the data we want since a dd is the next element we ' re getting it with the i + 1
function pickDetailField (field, arry) {
  return arry.reduce((p, c, i) => {
    if (c.tag === 'dt') {
      if (c.child[0].text === field) {
        if (field === 'Class&nbsp;date/time') {
          p = convertDateStringToDateObj(arry[i + 1].child[0].text);
        } else if (field === 'Room') {
          if (arry[i + 1].child) {
            p = {
              room    : arry[i + 1].child[0] ? arry[i + 1].child[0].child[0].text : '',
              building: arry[i + 1].child[1] ? arry[i + 1].child[1].child[0].text : '',
              address : arry[i + 1].child[2] ? arry[i + 1].child[2].child[0].text : ''
            };
          } else {
            p = {room: '', building: '', address: ''};
          }
        } else {
          p = arry[i + 1].child ? arry[i + 1].child[0].text : '';
        }
      }
    }
    return p;
  }, '');
}
function pickDetailField ( field , arry ) { return arry . reduce ( ( p , c , i ) => { if ( c . tag === 'dt' ) { if ( c . child [ 0 ] . text === field ) { if ( field === 'Class&nbsp;date/time' ) { p = convertDateStringToDateObj ( arry [ i + 1 ] . child [ 0 ] . text ) ; } else if ( field === 'Room' ) { if ( arry [ i + 1 ] . child ) { p = { room : arry [ i + 1 ] . child [ 0 ] ? arry [ i + 1 ] . child [ 0 ] . child [ 0 ] . text : '' , building : arry [ i + 1 ] . child [ 1 ] ? arry [ i + 1 ] . child [ 1 ] . child [ 0 ] . text : '' , address : arry [ i + 1 ] . child [ 2 ] ? arry [ i + 1 ] . child [ 2 ] . child [ 0 ] . text : '' } ; } else { p = { room : '' , building : '' , address : '' } ; } } else { p = arry [ i + 1 ] . child ? arry [ i + 1 ] . child [ 0 ] . text : '' ; } } } return p ; } , '' ) ; }
Look over the dt/dd list and find the data we want
since a dd is the next element we're getting it with the i+1
Look over the dt / dd list and find the data we want since a dd is the next element we ' re getting it with the i + 1
// This is a list of spans we need to parse through // an element that we need to grab text node from