Can someone help me turn this
entry = [
"start": "07:00 pm",
"end": "07:45 pm",
"rule": "MO,WE", <<<<
"summary": "test1"
];
into:
array = [
{
"start": "07:00 pm",
"end": "07:45 pm",
"rule": "MO,WE",
"summary": "test1",
"day": "WE" <<<<
},
{
"start": "07:00 pm",
"end": "07:45 pm",
"rule": "MO,WE",
"summary": "test1",
"day": "WE" <<<< (I get this but instead it should be "MO")
}
];
here is the code that I tried for getting the array... but it didn't work...
var temprule = entry.rule; //"MO,WE"
var rulest =[];
rulest = temprule.split(',');
for(var j = 0; j < rulest.length; j++) {
var obj1 = Object.assign(rulest[j]);
entry.day = obj1; //getting only WE each time when the array passes
jsondata.push(entry); // it has all elements like start,end,summary,rule and we need to add day to this...
}
I am not sure why it keeps adding same value in day though its looped through all different rules. Is that achievable throught code ?
Thanks!
entry=["start":"07:00 pm","end":"07:45 pm","rule": "**MO,WE**","summary":"test1"]not a valid jsentryis an array and not an object?