Skip to content

Instantly share code, notes, and snippets.

@kadzany
Created August 16, 2023 04:11
Show Gist options
  • Save kadzany/524516d505cc4d8fcf613c0ff00bcefe to your computer and use it in GitHub Desktop.
Save kadzany/524516d505cc4d8fcf613c0ff00bcefe to your computer and use it in GitHub Desktop.
const inputObject = {
"id": "06b9d100-3be3-11ee-91f1-a51199ffd3c6",
"product_name": "test wednesday 1122 aug",
"product_photo": null,
"product_test_type": "Security Testing, Heuristic Evaluation, Usability Testing",
"product_sub_test_type": "sub test",
"product_link": "product link",
"product_description": "test wednesday 1122 aug",
"service_id": "0f3c3d3e-90b7-11e9-9944-e03f49b834fa",
"status": "",
"created_at": "2023-08-16T03:14:35.165Z",
"updated_at": null,
"attachment_requirement": "lorem",
"requested_by": "7ac36970-90fb-11eb-a0a6-db5391efd2b6",
"checked_by": null,
"finished_at": null,
"revenue": "123",
"micro_impact": "123",
"mega_impact": "123",
"unit": "unit",
"tribe": "76846fc0-0da1-11ed-8c1b-2bdf64592e88",
"product": "a2293a20-0da1-11ed-8c1b-2bdf64592e88",
"note": "",
"versi": "test",
"peserta": null,
"label": null,
"status_name": "PROSES_PERBAIKAN",
"is_priority": true,
"platform_type": "ios",
"detail_feature_upgrade": "lorem",
"is_legion_std_ut": true,
"is_legion_std_he": true
};
const testTypes = inputObject.product_test_type.split(', ');
const result = {};
testTypes.forEach(testType => {
const newObj = { ...inputObject };
newObj.product_test_type = testType.trim();
if (!result[testType]) {
result[testType] = [];
}
result[testType].push(newObj);
});
console.log(result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment