Skip to content Skip to sidebar Skip to footer

Searching For Character In Json Using Javascript

[ {'lastName':'Noyce','gender':'Male','patientID':19389,'firstName':'Scott','age':'53Y,'}, {'lastName':'noyce724','gender':'Male','patientID':24607,'firstName':'rita','age':'0Y,'}

Solution 1:

Assuming you searchBarInput is equal to "n", Try this:

var results = []; // initialize array of results
for (var i = 0; i < recentPatientsList.length; ++i) {
  if (recentPatientsList[i].lastName.indexOf(searchBarInput) == 0) {
    results.push(recentPatientsList[i].lastName);
  }
}
alert('Results: ' + results.toString());

Post a Comment for "Searching For Character In Json Using Javascript"