Return matched value in Multidimensional Javascript Array

[email protected]

by Ryan Brackett

HTML

Change the variable "label" to another label in the javascript panel below.

CSS

body {
  font-family: Arial;
  line-height: 1.6em
}

JavaScript

var practiceGroup = 'The Heart Center Braselton';

var practiceDataArray = [


  {
    'label': 'Northeast Georgia Physicians Group',
    'name': 'Northeast Georgia Physicians Group',
    'logoURL': '//www.nghs.com/images/group-logos/ngpg-logo.gif',
    'insuranceURL': '//www.ngpg.org/insurance'
  },{
    'label': 'The Heart Center',
    'name': 'The Heart Center',
    'logoURL': '//www.nghs.com/images/group-logos/thc-logo.gif',
    'insuranceURL': '//www.heartngmc.org/insurance'
  }, {
    'label': 'Northeast Georgia Diagnostic Clinic',
    'name': 'Northeast Georgia Diagnostic Clinic',
    'logoURL': '//www.nghs.com/images/group-logos/ngdc-logo.gif',
    'insuranceURL': '//www.ngdc.com/insurance'
  }, {
    'label': 'The Longstreet Clinic',
    'name': 'The Longstreet Clinic, PC',
    'logoURL': '//www.nghs.com/images/group-logos/tlc-logo.gif',
    'insuranceURL': '//www.longstreetclinic.com/insurance'
  }, {
    'label': 'Gainesville Heart and Vascular',
    'name': '',
    'logoURL': '',
    'insuranceURL': '//gainesvilleheartgrp.com/faq'
  }, {
    'label': 'Kidney Care Center',
    'name': '',
    'logoURL': '',
    'insuranceURL': '//www.kidneycarega.com/resources/'
  }, {
    'label': 'Specialty Clinics of Georgia',
    'name': '',
    'logoURL': '',
    'insuranceURL': '//www.scg-ortho.com/our-services/'
  }



];


// SET THE FRAME OF REFERENCE FOR THE DATASET


for (var i = 0; i < practiceDataArray.length; i++) {
  
  if (practiceGroup.indexOf(practiceDataArray[i].label) != -1) {

    console.log("Found this in the array: " + practiceDataArray[i].name);

    

    return practiceGroup;
  } else {


    return practiceGroup;

  }
}