this is my data which i am getting through the form.
var subject = {
"items":[
{
"EmailType":"INVITATION",
"name":"INVITATION",
"subject":"Welcome to Transcendental Meditation India",
"from":"[email protected]",
"body":"hello",
"active":true,
"confidential":false,
"numberOfDaysToWait":1,
"sequentialOrder":3
},
{
"EmailType":"Create New",
"name":"sweeeee",
"subject":"eeee",
"from":"[email protected]",
"body":"hello2",
"active":false,
"confidential":true,
"numberOfDaysToWait":1,
"sequentialOrder":2
}
]}
I am using the loop to create another array of object which looks like this after modifying subject.
"Catitems": [
{
"template": {
"name": "Series 1 email",
"from": "TEAMGMG",
"subject": "GROUP2 - SERIES1 - EMAIL",
"body": "<html><body><strong>My test email</strong></body></html>",
"confidential": true,
"active": true
},
"sequentialOrder": 1,
"numberOfDaysToWait": 0,
}, {
"template": {
"name": "Series 2 email",
"from": "TEAMGMG",
"subject": "GROUP2 - SERIES2 - EMAIL",
"body": "<html><body><strong>My test email2</strong></body></html>",
"confidential": true,
"active": true
},
"sequentialOrder": 2,
"numberOfDaysToWait": 10,
}
]
I Have tried to manipulate the Subject with this loop but can not be able to set the property.
var Catitems={};
for(var i=0; i<subject.items.length ; i++){
Catitems[i]["name"]= subject.items[i].EmailType
}
console.log(item);