'use strict';

angular.module('parkLocator').filter('selectedActivities', function() {
  
  var filtered;
  
  return function(parkMarkers, activities) {
    console.log(parkMarkers);
    console.log(activities);

    if (activities.length <= 0) {return parkMarkers;}

    filtered = [];

  	parkMarkers.forEach( function (marker) {

      for (var i = 0; i < activities.length; i++) {
        // If the attribute exists, display the park in the map (e.g. marker['gym'])
        if ( marker[ activities[i].name.replace(/\s+/g, '').toLowerCase() ] ) {
          filtered.push(marker);
        }
      }

    });

    return filtered;
  };
});
@@ -93,24 +93,29 @@
 var filtered
+ = %5B%5D
 ;%0A  %0A  retur
@@ -279,21 +279,43 @@
 filtered
- = %5B%5D
+.splice(0, filtered.length)
 ;%0A%0A  %09pa

work around infdig loop issue