How to change just value in object key?
Ex: I would like to update keyvalue list_one
to anything value.
var ar = [
{
"list_one": [
{ id:1,product: 'Fortenza'}
]
},
{
"list_two": [
{ id:4,product:'SETLIQUI'}
]
}
]
My code:
var setTitleProduct = function(key="list_one",index=0) {
Object.keys(ar[index][key])[0] = 'new value'; //I know this doesnt work
console.log(ar[index][key]);
}
setTitleProduct("list_one",0)
Like this. https://i.stack.imgur.com/2U9gd.png