title: How to update json value in localstorage
body: <p>So I have an array stringify'ed and saved in my localStorage under 'persons' key.</p>
  
  <pre><code>arr = [{"name":"a", "age": 1, "sport":"football"},
  {"name":"b", "age": 2, "sport":"volley"},
  {"name":"c", "age": 3, "sport":"basket"}];
  localStorage.setItem('persons', JSON.stringify(arr));
  </code></pre>
  
  <p>When I need to update age for person with name x (lets say the input is person with name b), my approach is to get and parse my localStorage key:</p>
  
  <pre><code>var persons = JSON.parse(localStorage.persons);
  </code></pre>
  
  <p>Then I make a for loop to loop through the objects and find object with name b:</p>
  
  <pre><code>for (var i = 0; i &lt; persons.length; i++) {
     if(inputName === persons[i].name){
         persons[i].age += 2
         localStorage.setItem("persons", JSON.stringify(aCustomers[i].age));
     }
  }
  </code></pre>
  
  <p>This doesnt seem to work.
  I've found my match in the loop, but I dont know how to add 2 years to the age and update that value in my <code>localStorage.persons</code> without overwriting and destroying the json objects.</p>