I have the below array which is being passed from other component.
var myArray = [
{
"Sequence": 1,
"Value": 1,
"sections": [
{
"Name": "Section 1",
"Configurations": [
{
"Number": 1,
"Value": "Fruit"
},
{
"Number": 2,
"Value": "Vegetable"
}
],
"Cost": {
"Currency": "INR"
}
}
]
}
]
I want to loop through this array and add "isFruit" = true
if "Value": "Fruit"
and "isVegetable" = true
if "Value": "Vegetable"
.
So the Expected Output is as below.
var myArray = [
{
"Sequence": 1,
"Value": 1,
"sections": [
{
"Name": "Section 1",
"Configurations": [
{
"Number": 1,
"Value": "Fruit",
"isFruit": true
},
{
"Number": 2,
"Value": "Vegetable"
"isVegetable": true
}
],
"Cost": {
"Currency": "INR"
}
}
]
}
]
Seems the object is ready only and when I try as below it doesn't work. Tried with Spread Syntax but it goes only till 1 level and nested objects are still read only.
Someone please let me know how can I achieve the expected Output array.