title: Check for duplicate items before pushing
body: <p>Good morning,</p>
  
  <p>I'm wanting to push new items to an array (which we can do) but before pushing check for duplicates to prevent duplicating items within the array. </p>
  
  <p>I've tried this <strong><a href="http://jsfiddle.net/u8Fuk/10/" rel="nofollow">example</a></strong>, unsuccessfully I haven't managed to get this working with our code. </p>
  
  <p>If anyone know of a better solution or can see where we are going wrong please let us know asap.
  Thank you.</p>
  
  <p>** JS **</p>
  
  <pre><code> $scope.Products = $scope.$storage.Products == undefined ? [] : $scope.$storage.Products;
   $scope.logItem = function($index, brandName, partNumber, productName, amount) {
  
       $scope.newItem = {
           Brand: brandName,
           Part: partNumber,
           Product: productName,
           Amount: amount
       };
  
       var duplicateItem = $scope.Products.reduce(function(previous, i) {
           if ($scope.newItem === i) return true;
           return previous
       }, false);
  
       if (duplicateItem) {
           alert("Already Logged");
       } else {
           alert("Item Logged");
           $scope.Products.push($scope.newItem);
           $scope.$storage.Products = $scope.Products;
       }
  
  
   }
  </code></pre>
  
  <p>** FIX **</p>
  
  <pre><code>$scope.Products = $scope.$storage.Products == undefined ? [] : $scope.$storage.Products;
  $scope.logItem = function($index, brandName, partNumber, productName, amount) {
      $scope.newItem = {
          Brand: brandName,
          Part: partNumber,
          Product: productName,
          Amount: amount
      };
      var isDuplicate = false;
      $scope.Products.forEach(function(element) {
          if (JSON.stringify(element) === JSON.stringify($scope.newItem)) {
              isDuplicate = true;
              return false;
          }
      });
      if (!isDuplicate) {
          alert("Item Logged");
          $scope.Products.push($scope.newItem);
          $scope.$storage.Products = $scope.Products;
      } else {
          alert("Already Logged");
      };
  
  }
  </code></pre>