function showPage(pageNum, sortStyle){
  let infoName;
  if(pageNum === 1){
    infoName = 'data/page-1.json';
  } else {
    infoName = 'data/page-2.json';
  }

  let sortedHorns = [];
  
  const success = hornsData => {
    if (sortStyle === 'alphabet'){
      sortedHorns = sortAlphabetically(hornsData);
    } else {
      sortedHorns = sortNumerically(hornsData);
    }
    addHorns(sortedHorns);
    addOptions(sortedHorns);
    addOptionsListeners(sortedHorns);

  }

  $.get(infoName, 'json')
    .then(success)
    .catch(error => console.error(error));
}
//Gets data from json, displays depending on page number chosen

Gets data from json, displays depending on page number chosen
Gets data from json displays depending on page number chosen
function showPage(pageNum, sortStyle){
  let infoName;
  if(pageNum === 1){
    infoName = 'data/page-1.json';
  } else {
    infoName = 'data/page-2.json';
  }
  let sortedHorns = [];
  const success = hornsData => {
    if (sortStyle === 'alphabet'){
      sortedHorns = sortAlphabetically(hornsData);
    } else {
      sortedHorns = sortNumerically(hornsData);
    }
    addHorns(sortedHorns);
    addOptions(sortedHorns);
    addOptionsListeners(sortedHorns);
  }
  $.get(infoName, 'json')
    .then(success)
    .catch(error => console.error(error));
}
function showPage ( pageNum , sortStyle ) { let infoName ; if ( pageNum === 1 ) { infoName = 'data/page-1.json' ; } else { infoName = 'data/page-2.json' ; } let sortedHorns = [ ] ; const success = hornsData => { if ( sortStyle === 'alphabet' ) { sortedHorns = sortAlphabetically ( hornsData ) ; } else { sortedHorns = sortNumerically ( hornsData ) ; } addHorns ( sortedHorns ) ; addOptions ( sortedHorns ) ; addOptionsListeners ( sortedHorns ) ; } $ . get ( infoName , 'json' ) . then ( success ) . catch ( error => console . error ( error ) ) ; }
Gets data from json, displays depending on page number chosen
Gets data from json displays depending on page number chosen