Given I have an array of \"purpose\" objects:
//array of purpose objects: var purposeObjects = [ {purpose: \"daily\"}, {purpose: \"weekly\"}, {pu
The error was that you cannot use this in the grep, but you must use a reference to the element. This works:
this
function findPurpose(purposeName){ return $.grep(purposeObjects, function(n, i){ return n.purpose == purposeName; }); }; findPurpose("daily");
returns:
[Object { purpose="daily"}]