I'm searching an array of objects using jquery grep and would like to include wildcards in the search. For example, I have an array as follows:
courses = [
{code: 'ENCH3TH', otherFields: otherStuff},
{code: 'ENCH3THHS1', otherFields: otherStuff},
{code: 'ENCH3TH2', otherFields: otherStuff},
{code: 'ENCH4RT', otherFields: otherStuff},
{code: 'ENCH4MT', otherFields: otherStuff}]
I'd like to get all the courses with the ENCH3TH prefix. I have attempted
var resultSet = $.grep(courses, function(e){ return e.code == 'ENCH3TH/'; });
..to no avail (note the use of the '/' after 'ENCH3TH' as the wildcard).
/a wildcard?