Having an array with multiple objects raises a question.
var profile = [
{"MODE":"Comfort","MONDAY":"09:00:00","TUESDAY":"09:00:00","WEDNESDAY":"09:00:00",
"THURSDAY":"09:00:00","FRIDAY":"09:00:00","SATURDAY":null,"SUNDAY":null},
{"MODE":"Eco","MONDAY":"22:00:00","TUESDAY":"22:00:00","WEDNESDAY":"22:00:00",
"THURSDAY":"22:00:00","FRIDAY":"22:00:00","SATURDAY":null,"SUNDAY":null},
{"MODE":"Standby","MONDAY":"07:30:00","TUESDAY":"07:30:00","WEDNESDAY":"07:30:00",
"THURSDAY":"07:30:00","FRIDAY":"07:30:00","SATURDAY":null,"SUNDAY":null},
{"MODE":"Standby","MONDAY":"21:00:00","TUESDAY":"21:00:00","WEDNESDAY":"21:00:00",
"THURSDAY":"21:00:00","FRIDAY":"21:00:00","SATURDAY":null,"SUNDAY":null}
];
In this array, MODE along with several week days are distinguishable properties.
The aim is to organize MONDAY values under an array named MONDAY, TUESDAY values under TUESDAY, and so on. The key of each value should match the corresponding MODE (comfort, eco, etc).
To clarify:
var MONDAY = ["Comfort":"09:00:00","ECO":"22:00:00", ...]
var TUESDAY = ["Comfort":"09:00:00","ECO":"22:00:00",...]
An attempt was made to filter the initial array
var comfort = profile.filter(p => p.MODE == "Comfort");
var eco = profile.filter(p => p.MODE == "Eco");
var standby = profile.filter(p => p.MODE == "Standby");
var comfortMode = comfort[0];
var ecoMode = eco[0];
var standbyMode0 = standby[0];
var standbyMode1 = standby[1];
console.log(ecoMode["MONDAY"]);
console.log(standbyMode0["MONDAY"]);
However, reaching a point where manual input seems necessary has caused a roadblock
var MONDAY = [ecoMode["MONDAY"],comfortMode["MONDAY"],standbyMode0["MONDAY"],standbyMode1["MONDAY"]];
var TUESDAY = [...,...,...,...]
Are there alternative methods for creating loops that arrange all MONDAY values from comfortMode, ecoMode, and other arrays into an array named MONDAY?