title: How to access JSON database using javascript
body: <p>How can I find "firstname" with value "Anna" and display her "lastname" at the end using JavaScript? This is just a dummy example for me to understand how it works.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var employees = [
      {
      "firstName":"John",
      "lastName":"Doe"
      }, 
      {
      "firstName":"Anna",
      "lastName":"Smith"
      },
      {
      "firstName":"Peter",
      "lastName":"Jones"
      }
  ];
  
  document.getElementById("demo").innerHTML =
  employees.firstName;</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;p id="demo"&gt;&lt;/p&gt;</code></pre>
  </div>
  </div>
  </p>