The error was that you cannot use this
in the grep, but you must use a reference to the element. This works:
function findPurpose(purposeName){
return $.grep(purposeObjects, function(n, i){
return n.purpose == purposeName;
});
};
findPurpose("daily");
returns:
[Object { purpose="daily"}]