I have an array, I need to return a restaurant\'s name, but I only know the value of its \"food\" attribute (not it\'s index number).
For example, how could I return
you can use ES5 some. Its pretty first by using callback
function findRestaurent(foodType) { var restaurant; restaurants.some(function (r) { if (r.food === id) { restaurant = r; return true; } }); return restaurant; }