-1
I have the following object below:
const usuario = {
nome: 'Diego',
idade: 23,
endereco: {
cidade: 'Rio do Sul',
uf: 'SC',
pais: 'Brasil',
}
};
I’m gonna create a usuario2
based on the object usuario
above, however, I will change the name to Gabriel
const usuario2 = { ...usuario, nome: 'Gabriel' };
succeeded.
Now I’m gonna try to create a usuario3
, but changing the city to Lontras.
const usuario3 = { ...usuario, endereco: {cidade: 'Lontras'}};
did not succeed.
What’s the right way to do this metamorphosis, where I hold one object within another?
it was not very clear your problem, put the whole code with the expected result to be easier
– Ricardo Pontual