How to return from a $.each operation? (jQuery)

Viewed 1175

Example:

var t = $.each(templos_cache, function(f,g){
 $.each(g.requer, function(h,j){
  if (parseFloat(g.id) == id){
   alert(j.nome); // OK, return 'afrodite'.
   return j.nome; // wrong, return [Object object].
  }
  });
  return '';
 });

Looking at the code we can see the problem... i can do a set in a variable out of scope but i think that can exist some more elegant way to do this.

4 Answers
Related