angular.module('starter.services', [])

.factory('Unicorns', function($http) {
  var obj = {
    gifs: [],
    term: 'unicorns'
  };

  return {
    search: function(term){
      obj.term = term;
      return $http.get('http://api.giphy.com/v1/gifs/search?q=' + obj.term + '&limit=10&api_key=dc6zaTOxFJmzC')
      .then(function(response){
        gifs = response.data;
        return gifs;
      });
    },
    GetMoreGifs: function(array){
      return $http.get('http://api.giphy.com/v1/gifs/search?q=' + obj.term + '&limit=10&offset=' + array.length + '&api_key=dc6zaTOxFJmzC')
      .then(function(response){
        gifs = array.concat(response.data.data);
        return gifs;
      });
    }
  }
})

.factory('Trending', function($http) {
  var obj = {
    gifs: []
  };

  return {
    GetTrending: function() {
      return $http.get("http://api.giphy.com/v1/gifs/trending?limit=10&api_key=dc6zaTOxFJmzC")
      .then(function(response) {
        gifs = response.data;
        return gifs;
      });
    },
    GetMoreGifs: function(array){
      return $http.get('http://api.giphy.com/v1/gifs/trending?limit=10&offset=' + array.length + '&api_key=dc6zaTOxFJmzC')
      .then(function(response){
        gifs = array.concat(response.data.data);
        return gifs;
      });
    }
  }
})

.factory('User', function() {
  var obj = {
    favorites: []
  };

  return {
    addGifToFavorites: function(gif) {
      obj.favorites.unshift(gif);
    },
    returnFavorites: function() {
      return obj.favorites;
    }
  }
});

















@@ -1353,32 +1353,202 @@
 rites: %5B%5D%0A  %7D;%0A%0A
+  function isDuplicateGif(gif) %7B%0A    if (!obj.favorites) return false;%0A    return obj.favorites.some(function(savedGif)%7B%0A      return savedGif.id === gif.id;%0A    %7D)%0A  %7D%0A%0A
   return %7B%0A    a
@@ -1582,24 +1582,50 @@
 gif) %7B%0A     
+ if (!isDuplicateGif(gif))
  obj.favorit

Remove ability to add same gif as favorite