function setUsername(id, newUsername) { for (var i = 0; i < jsonObj.length; i++) { if (jsonObj[i].Id === id) { jsonObj[i].Username = newUsername; return; } } } // Call as setUsername(3, "Thomas");