Suppose we have an JSON array as below.
var details = [
{“name”:x,”email”:”test@gmail.com},
{“name”:y,”email”:”test1@gmail.com},
]
To get Y’s email id use the below function
function findElement(arrayName, nameValue) {
for (var i = 0; i < arr.length; i++)
if (arr[i]["name"] == propValue)
return arr[i]["email"];
// will return undefined if not found; you could return a default instead
}