title: Else condition in javascript is not working
body: <p>I have a program like this</p>
  
  <pre><code>var contacts = [
      {
          "firstName": "Akira",
          "lastName": "Laine",
          "number": "0543236543",
          "likes": ["Pizza", "Coding", "Brownie Points"]
      },
      {
          "firstName": "Harry",
          "lastName": "Potter",
          "number": "0994372684",
          "likes": ["Hogwarts", "Magic", "Hagrid"]
      },
      {
          "firstName": "Sherlock",
          "lastName": "Holmes",
          "number": "0487345643",
          "likes": ["Intriguing Cases", "Violin"]
      },
      {
          "firstName": "Kristian",
          "lastName": "Vos",
          "number": "unknown",
          "likes": ["Javascript", "Gaming", "Foxes"]
      }
  ];
  
  
  function lookUpProfile (firstName, prop) {
      // Only change code below this line
  
      for (var i = 0; i &lt;= contacts.length; i++) {
          if (contacts[i].firstName===firstName) {
              if (contacts[i].hasOwnProperty(prop)) {
                  return contacts[i][prop];
              } else {
                  return "No such property";
              }
          }
      }
  }
  
  // Change these values to test your function
  lookUpProfile("Harry", "likes");
  </code></pre>
  
  <p>The problem is that if I do not use <code>else</code> condition, the above code works with no problem. But when I add <code>else</code> condition, the first condition does not execute.</p>
  
  <pre><code>var contacts = [
      {
          "firstName": "Akira",
          "lastName": "Laine",
          "number": "0543236543",
          "likes": ["Pizza", "Coding", "Brownie Points"]
      },
      {
          "firstName": "Harry",
          "lastName": "Potter",
          "number": "0994372684",
          "likes": ["Hogwarts", "Magic", "Hagrid"]
      },
      {
          "firstName": "Sherlock",
          "lastName": "Holmes",
          "number": "0487345643",
          "likes": ["Intriguing Cases", "Violin"]
      },
      {
          "firstName": "Kristian",
          "lastName": "Vos",
          "number": "unknown",
          "likes": ["Javascript", "Gaming", "Foxes"]
      }
  ];
  
  
  function lookUpProfile (firstName, prop) {
      // Only change code below this line
  
      for (var i = 0; i &lt;= contacts.length; i++) {
          if (contacts[i].firstName === firstName) {
              if (contacts[i].hasOwnProperty(prop)) {
                  return contacts[i][prop];
              } else {
                  return "No such property";
              }
          } else if (contacts[i].firstName !== firstName) {
              return "No such contact";
          }
      }
  }
  
  // Change these values to test your function
  lookUpProfile("Harry", "likes");
  </code></pre>
  
  <p>When I execute this code with <code>else</code> condition, the first condition does not execute and jumps directly to the <code>else</code> condition. What step am I missing or doing wrong please?</p>