Most elegant way to return value from within JQuery $.each?
<p>I was wondering if there a more elegant way of returning a value from the function I've pasted below : "getImageURLforPOICategory". </p>

<p>As you can see I've used JQuery's "each" function to iterate through an array of objects, when I find the matching value I want to return a result out of the "each" loop and then right out of the function that contains the each loop. </p>

<p>I've used a local variable to "cache" it and then I'm returning that. I'm not entirely sure if this is the best approach? Is there a way of returning the value directly from within the each loop?</p>

<pre><code>Tracker.getImageURLforPOICategory = function (POICategoryID) {
 var url;
 $.each(Tracker.pointofinterestcategories, function () {
  if (this.id === POICategoryID) {
   url = this.imageurl;
   return;
  }
 }
 );
 return url;
};
</code></pre>

<p>Thanks for reading,</p>

<p>Cheers,</p>

<p>Duncan</p>
