I am looking to group objects by partial name and assign them to variables
data =
{
SCHOOL-ADMISSION_YEAR: "2021"
SCHOOL-SCHOOL_NAME: "ABC SCHOOL"
SCHOOL-SCHOOL_LOCATION: "NEWYORK"
ENROLLMENT-ADMISSION_YEAR: "2021"
ENROLLMENT-SUBMISSION_DATE: "2020-04-02"
ENROLLMENT-ENROLLMENT_DATE: "2020-06-02"
}
The desired groups are
School =
{
ADMISSION_YEAR: "2021",
SCHOOL_NAME: "ABC SCHOOL",
SCHOOL_LOCATION: "NEWYORK",
}
Enrollment =
{
ADMISSION_YEAR: "2021",
SUBMISSION_DATE: "2020-04-02",
ENROLLMENT_DATE: "2020-06-02",
}
var school = data.filter(p => p.contains('SCHOOL'));
var enrollment = data.filter(p => p.contains('ENROLLMENT'));