I am trying to add a object title of Nicaragua to my another object in javascript. so it will describe the propertys of nicaragua. How would I do that. I am using the object.assign method but because it is only a variable I am assigning as a 3rd property it will not label my property’s of Nicaragua as being a Nicaraguan object.
Example
`{
buenosAires: {
depth: ‘400 meters’,
annualBudget: 1000000,
specimens: [ ‘Dilophosaurus’, ‘Brachiosaurus’ ]
},
mexico: {
depth: ‘350 meters’,
annualBudget: 900000,
specimens: [ ‘Gallimimus’, ‘Parasaurolophus’ ]
},
depth: ‘200 meters’,
annualBudget: 1500000,
specimens: [
‘Tyrannosaurus Rex’,
‘Stegosaurous’,
‘Triceratops’,
‘Velociraptor’,
‘T rex’
]
}
As you can see the last properties do not have a object label of nicaragua, but they were sucessfully joined. Here is the code I was working with to create the above below.
const nicaragua = {
depth: ‘200 meters’,
annualBudget: 1500000,
specimens: [
‘Tyrannosaurus Rex’,
‘Stegosaurous’,
‘Triceratops’,
‘Velociraptor’,
],
};
const hammondsMines = {
buenosAires: {
depth: ‘400 meters’,
annualBudget: 1000000,
specimens: [‘Dilophosaurus’, ‘Brachiosaurus’],
},
mexico: {
depth: ‘350 meters’,
annualBudget: 900000,
specimens: [‘Gallimimus’, ‘Parasaurolophus’],
},
};
Object.assign(hammondsMines,nicaragua)
console.log(hammondsMines)