I am trying to pass an array into a function that looks at a part of the current URL and then filters data on the page based on that URL. The array has many values a person could search for on the page.
Currently the filterFor param can only take a single string and I want it to take a array of strings that could be searched for.
function queryList(filterFor, filterClass, filterClassTwo) {
var searchResult = $.urlParam('filter');
if (searchResult === filterFor) {
degreeProgram.filter(function (item) {
if (item.values()[filterClass] === filterFor ||
item.values()[filterClassTwo] === filterFor) {
return true;
} else {
return false;
}
});
$('#filterDisplay').html('<span>' + filterFor + '</span>');
$('#filterDisplay').addClass('activated');
}
}
queryList('Chemistry', 'programName');
This would allow the page to filter to show any programName with the value of chemistry. The part of the URL the function looks at is this:
?filter=Chemistry
I need it to work like this:
var myArray = ['Chemistry', 'Math' 'Earth Science'];
queryList(myArray, 'programName');
allowing me to pass in a list of programs that the query could take in.