title: Function, return last object thats value(s) are equal to something. (JavaScript)
body: <p>I want a function which checks for each object in an array if a value is the same as in the object.</p>
  
  <p>But I don't want to return all objects where this is true, and also not the first, I want to return only the last object where <code>name = array[i].name</code>.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var allInfo = [
    {name: "Olaf", lastname: "Kranz", age:33},
    {name: "Mark", lastname: "Alien", age:21},
    {name: "Cindy", lastname: "Sunsi", age:65},
    {name: "Anna", lastname: "Pitter", age:20},
    {name: "Piet", lastname: "Schmitz", age:29}
  ];
  
  var name = 'Cindy';
  document.write(getIfNameIsAvailable(name));
  
  
  function getIfNameIsAvailable(name) {
    for (i = allInfo.length; i &gt;= 0; i--) {
      if (allInfo[i].name == name) {
        return allInfo[i].lastname;
        break;
      }
    }
  };</code></pre>
  </div>
  </div>
  </p>