JSFiddle - React, Tailwind, and code Playground
by Shin Okada
JavaScript
var myobj = [{
"id": 1,
"title": "yoga class 6",
"description": null,
"room_id": 1,
"capacity": 6,
"color": "#00aabb",
"all_day": 0,
"start": "2017-06-12 10:00:00",
"end": "2017-06-12 13:00:00",
"repeat": 0,
"created_at": "2017-06-07 09:01:19",
"updated_at": "2017-06-07 17:19:24",
"repeatevents": []
}, {
"id": 6,
"title": "yoga class",
"description": null,
"room_id": 1,
"capacity": 20,
"color": "#00aabb",
"all_day": 0,
"start": "2017-06-10 17:30:00",
"end": "2017-06-10 19:00:00",
"repeat": 1,
"created_at": "2017-06-07 09:49:32",
"updated_at": "2017-06-07 09:55:16",
"repeatevents": [{
"id": 2,
"event_id": 6,
"dow": "s:5:\"1,3,6\";",
"date_start": "2017-06-09",
"date_end": "2017-08-10",
"time_start": "09:49:00",
"time_end": "10:49:00",
"created_at": "2017-06-07 09:49:32",
"updated_at": "2017-06-07 09:49:32"
}]
}, {
"id": 7,
"title": "yoga class",
"description": null,
"room_id": 1,
"capacity": 4,
"color": "#00aabb",
"all_day": 0,
"start": "2017-06-09 14:30:00",
"end": "2017-06-09 15:30:00",
"repeat": 1,
"created_at": "2017-06-07 09:53:41",
"updated_at": "2017-06-07 09:53:41",
"repeatevents": [{
"id": 3,
"event_id": 7,
"dow": "s:5:\"2,4,6\";",
"date_start": "2017-06-09",
"date_end": "2017-06-30",
"time_start": "09:53:00",
"time_end": "10:53:00",
"created_at": "2017-06-07 09:53:41",
"updated_at": "2017-06-07 09:53:41"
}]
}];
var repeatEvents = [];
var norepeatEvents = [];
for (var key in myobj) {
if (myobj.hasOwnProperty(key)) {
if (myobj[key]['repeat']) {
repeatEvents.push(myobj[key]);
} else {
norepeatEvents.push(myobj[key]);
}
//myobj.eventCreater;
//console.log(key + " -> " + myobj[key]);
}
};
console.log(repeatEvents);
console.log(norepeatEvents);