title: Changing localStorage with <input type="text">
body: <p>I am making a forum with an admin panel, where the admin can change the information users provide.</p>
  
  <p>I am retrieving the user from localStorage to an <code>&lt;input type="text"&gt;</code>, but I am not able to change the information and save it in the localStorage.</p>
  
  <p>I get the erorr <code>Uncaught TypeError: Cannot set property 'firstName' of undefined</code> every time I click the edit button.</p>
  
  <p>P.S: School project.</p>
  
  <pre><code>function seeUser(){
      $(document).on('click', ".user .glyphicon-edit", function() {
          var dataPage = "PersonalProfile";
          var personalProfileDiv = $("#personalProfile");
          $(".MyPage").css({"display":"none"});
          $("#personalProfile").html("");
  
          personalProfileDiv.append("&lt;input type='text' id='userName' value='"+arrayUsers[$(this).parent().parent().attr("data-userId")].firstName+"'&gt;");
          personalProfileDiv.append("&lt;input type='text' id='userLastname' value='"+arrayUsers[$(this).parent().parent().attr("data-userId")].lastName+"'&gt;");
          personalProfileDiv.append("&lt;input type='text' id='userE-mail' value='"+arrayUsers[$(this).parent().parent().attr("data-userId")].email+"'&gt;");
          personalProfileDiv.append("&lt;input type='text' id='userPassword' value='"+arrayUsers[$(this).parent().parent().attr("data-userId")].password+"'&gt;");
          personalProfileDiv.append("&lt;button class='btn btn-primary btn-lg' data-userId='"+loggedInUserId+"' id='editUserBtn'&gt;Edit user&lt;/button&gt;");
      });
  }
  
  $(document).on('click', "#editUserBtn", function() {
      var userId = $(this).attr("data-userId");
      var userFirstNameChange = $(this).prev().prev().prev().prev().val();
      var userLastNameChange = $(this).prev().prev().prev().val();
      var userEmailChange = $(this).prev().prev().val();
      var userPasswordChange = $(this).prev().val();
      arrayUsers[userId].firstName = userFirstNameChange;
      arrayUsers[userId].lastName = userLastNameChange;
      arrayUsers[userId].email = userEmailChange;
      arrayUsers[userId].password = userPasswordChange;
      localStorage.users = JSON.stringify(arrayUsers);
  });
  </code></pre>