Solve the problem using spread operator #3
Question:
Change the value of m inside the obj using spread operator.
let obj = {
g: 5,
h: {
i: 6,
j: 7,
k: {
l: 8,
m: 9,
},
},
};
Answer:
let objNew = { ...obj, h: { ...obj.h, k: { ...obj.h.k, m: 10 } } };
console.log(objNew);
// Output:{ g: 5, h: { i: 6, j: 7, k: { l: 8, m: 10 } } }