Add element into existing element inside object

Add element into existing element inside object
0

#1

Hi there,

My dog is lonely, she only has one friend which is Linda.

var ourDog = {
“name”: “Camper”,
“legs”: 4,
“tails”: 1,
“friends”: [“Linda”]
};

How do I add Robert and John to be my dog’s friends ?

var ourDog = {
“name”: “Camper”,
“legs”: 4,
“tails”: 1,
“friends”: [“Linda”, “Robert”, “John”]
};

Thanks for all your help.


#2

Markus Kiili help me in Gitter, the solution is

ourDog.friends.push(“Robert”, “John”);