I have an object with this static structure:
let obj = {
"id": "",
"id_configuration": "",
"comment": "",
"mw_assigned": "",
};
I want to update it's properties by key. For example, if I receive
const key = 'mw_assigned'
const value = '23'
Then I want to update the object and to have:
let obj = {
"id": "",
"id_configuration": "",
"comment": "",
"mw_assigned": "23",
};
How could I do? I was trying to create a new object, something like this:
const new_obj = { ...obj, key: value }
I don't know how to set the name of the key and value from the vars