title: Check For Uniqueness in Array, Push To Array if Unique
body: <p>Using AngularJS, I'm creating an addTodo function in my app.</p>
  
  <p>I seem to be having trouble implementing a way to check the uniqueness of the object being added to the array, and having it followed by additional actions. </p>
  
  <p>So far I'm able to get the additional actions working, but not the initial check for uniqueness. How can I implement the check for uniqueness action and then have it followed by the additional actions?</p>
  
  <p>The addTodo function I'm trying to create flows like this (<strong>Bold</strong> means not implemented):</p>
  
  <p><strong></p>
  
  <ol>
  <li><p>Check if todo is already in todos</strong></p>
  
  <p>1a. <strong> If it does exisit, don't push, display alert</strong></p></li>
  <li><p>Check if todo is not blank</p>
  
  <p>2a. If it is blank, don't push, display alert</p></li>
  <li><p>If unique and not blank, push to todos, display success message</p></li>
  </ol>
  
  <p>Current addTodo function (without unqiueness check):</p>
  
  <pre><code>$scope.addTodo = function(){
    $scope.isVisible = true;
    if ($scope.todo) {
      $scope.todos.push($scope.todo);
      $scope.todo = '';
      $scope.alert = $scope.alerts[1];
    }else{
      $scope.alert = $scope.alerts[0];
    }
  };
  </code></pre>
  
  <p><em>Note 1: <code>$scope.alert</code> and <code>$scope.alerts</code> are used to display certain error messages;</em></p>
  
  <pre><code>$scope.alerts[0]
  </code></pre>
  
  <p>"Please add text to your task."</p>
  
  <pre><code>$scope.alerts[1]
  </code></pre>
  
  <p>"Added a new task!"</p>
  
  <p>The alert I want to display if the task being added already exists is</p>
  
  <pre><code>$scope.alerts[3] 
  </code></pre>
  
  <p>"Task already in list."</p>
  
  <p><em>Note 2: <code>$scope.isVisible</code> toggles the visibility of the alert</em></p>