title: Compare object property to variable in localstorage in JavaScript
body: <p>Is it possible to compare an object property to a variable stored in localstorage using Javascript or Jquery? Here's what I mean...</p>
  
  <p>So I have an object like this:</p>
  
  <pre><code>var persons = [
    {
      "firstName": "Dwight",
      "surName": "Stender",
      "picture": "https://randomuser.me/api/portraits/med/men/99.jpg",
      "id": "1"
    }
  ]
  </code></pre>
  
  <p>And I have a variable stored in localstorage (the name is clickId). Now I want to compare the id from the object to that variable in localstorge. I can print them both to the console so I know they work. But when I try to compare them, it suddenly doesn't work anymore (even though the id and the variable contain the same number). This is how I compared the two:</p>
  
  <pre><code>for (i = 0; i &lt; persons.length; i++) {
      if (persons[i].id == localStorage.clickId) {
          document.getElementById("result").innerHTML = "yay"
      } else {
          document.getElementById("result").innerHTML = "nay"
      };
  };
  </code></pre>
  
  <p><strong>Note 1</strong> I have also tried comparing the two with <code>===</code> instead of <code>==</code></p>
  
  <p><strong>Note 2</strong> the statements to be executed inside the <code>if...else</code> are just placeholders for the purpose of explanation</p>