I have a js object like
[{"name":"John","group":"t1..." .....}]
so to create new user from same t1, I loop through the obj using
var new_user;
for(var i=0; i<users.length; i++) {
if(users[i].group === 'group name goes here') {
new_user = users[i];
break;
}
}
then is simply push it using users.push(new_user);
then I try to change the just the name using
var l = users.length - 1; users[l].name = 'Jack';
it changes the name for the all the users.
[{"name":"Jack","group":"t1..." .....},{"name":"Jack","group":"t1..." .....}]
I know I am doing something wrong. I appreciate any help.