I have an array of string values. I'd like to loop through the array and return any values that not only match the string values, but contain the values.What would be the best approach to this?
Here is what I have so far, which is searching for the exact value.
I'm using this logic is several places to match the url. For part of the site getLocation returns /about, /services, etc... There is also an admin part which returns /adminabout, /adminservices, etc.
var getLocation = $location.$$path;
var isCustom = ['about', 'services', 'volunteer', 'contact', 'give', 'blog'];
if(!isCustom.indexOf(getLocation) == -1){
$scope.isCustom = true || false;
}
getLocationcontains the slash, then it will never match any of those objects.= false || true- Delightful! You should read it aloud.