title: Find if values exists in an array of object (Angularjs)
body: <p>I am having a hard time trying to get this right. I would be glad if someone could help me get a solution for this. </p>
  
  <pre><code>0: Object
     Name: Ria
     Age: 27
     Sex: Female
  
  1: Object
     Name: Brian
     Age: 23
     Sex: Male
  
  2: Object
     Name: Rick
     Age: 32
     Sex: Male
  </code></pre>
  
  <p>Here is the array of objects. I am passing a user entered value. for e.g. I ask the user to enter the name. Once entered, i need to check in the above array of objects, if the Name is present in the array of objects. </p>
  
  <p>I tried a variety of solutions using foreach, basic array itereation and i couldnot find a way. </p>
  
  <p>Here is what i tried at the last...</p>
  
  <pre><code>var result = false;
  
  function search(nameKey, myArray) {
    for (var i = 0; i &lt; myArray.length; i++) {
      if (myArray[i].Name === nameKey) {
        return true;
      }
    }
  }
  
  result = search($scope.data.name, checkdatabase);
  </code></pre>
  
  <p>Here, <code>checkdatabase</code> is the array of objects and <code>$scope.data.name</code> is the user entered value. I am expecting the value of result as <code>true</code> when user is present in database or else result as <code>false</code> which is defined initially. </p>