title: foreach loop in angularjs
body: <p>I was going through the <code>forEach</code> <code>loop</code> in <code>AngularJS</code>. There are few points that I did not understood about it.</p>
  
  <ol>
  <li>What is the use of the iterator function? Is there any way to go without it?</li>
  <li>What is the significance of the key and value as shown below?</li>
  </ol>
  
  <p><code>angular.forEach($scope.data, function(value, key){});</code></p>
  
  <p><strong>PS:</strong> I tried to run this function without the arguments and it did not work.</p>
  
  <p>Here's my <code>json</code>:</p>
  
  <pre><code>[
     {
       "Name": "Thomas",
       "Password": "thomasTheKing"
     },
     {
       "Name": "Linda",
       "Password": "lindatheQueen"
     }
  ]
  </code></pre>
  
  <p>My <code>JavaScript</code> file: </p>
  
  <pre><code>var app = angular.module('testModule', []);
  
  app.controller('testController', function($scope, $http){
     $http.get('Data/info.json').then(
        function(data){
           $scope.data = data;
        }
     );
  
     angular.forEach($scope.data, function(value, key){
        if(value.Password == "thomasTheKing")
           console.log("username is thomas");
     });
  });
  </code></pre>
  
  <p><strong>Another question</strong>: Why the function above does not enter on if condition and print "username is thomas" in the console?</p>