I would like to know how to change the value in a nested object array using javascript.
how to change the "load": "undefined" to "load":1 in the obj
var obj=[{
"id": "service",
"country": "AR",
"load": "undefined"
},{
"id": "fund",
"country": "CA",
"load": "undefined"
}]
var result = obj.forEach(e=>e.load=1);
Expected Output:
[{
"id": "service",
"country": "AR",
"load": 1
},{
"id": "fund",
"country": "CA",
"load": 1
}]
loadandloadingforEachdoesn't return anything - you're instead changingobjin-place, so you can just return that, if needed.