0
I’m having a doubt in an exercise since yesterday and I can’t find anything on the net. The problem is this: I need to change the value of the CITY property and put another name on it, but when I try to change it, it rewrites the address field leaving only the value I tried to change.
Code below to contextualize:
const usuario = { nome: "Rafael", idade: 17,
endereco: { cidade: "Guatapará", uf: "SP", pais: "Brasil" }
};
const usuario2 = { ...usuario, endereco: { cidade: "Ribeirão Preto" } };
What I hope to get is this:
{ nome: 'Rafael', idade: 19, endereco: { cidade: "Ribeirão Preto", uf: "SP", pais: "Brasil" }}
But what I get is:
{ nome: 'Rafael', idade: 19, endereco: { cidade: 'Ribeirão' }}
As you can see, inside the address property only remained the city. How can I correct this?