jquery - get value from array object
<p>I have an array of object that look like this</p>

<pre><code>var result = [{"id":"1","price":"20.46"},{"id":"2","price":"40.00"}]
</code></pre>

<p>right now I can access it by</p>

<pre><code>result[0].price 
</code></pre>

<p>but what I am trying to do is loop through the array of object, and compare the id to a user inputed id and return the matching value. So the index should be irrelevant</p>

<p>I tried to loop through the array of object, but I probably made some grammar mistake and got nothing back. </p>

<pre><code>var userinputid = 1;

result.forEach(function(){
     if(userinputid == result.id){
     alert(result.price);
  });
</code></pre>

<p>How to solve this. </p>