update localstorage value
var persons = JSON.parse(localStorage.persons);
for (var i = 0; i < persons.length; i++) {
if(inputName === persons[i].name){ //look for match with name
persons[i].age += 2; //add two
break; //exit loop since you found the person
}
}
localStorage.setItem("persons", JSON.stringify(persons));
Comments
Post a Comment