maplol123@gmail.com,
<script>
const data = [{
"QUESTION": "61771",
"ANSWERS": "2772718",
"CORRECT": "1,2,3,4"
},
{
"ANSWERS": "7271717"
},
{
"ANSWERS": "272727"
},
{
"ANSWERS": "6271717"
},
{
"QUESTION": "716171781",
"ANSWERS": "6171717",
"CORRECT": "1,2"
},
{
"ANSWERS": "7171616"
},
{
"ANSWERS": "287272"
}
]
const createData = data => {
let totall = [], ar = [];
for (let {QUESTION, ANSWERS, CORRECT} of data) {
if (QUESTION) {
ar = ANSWERS = [ANSWERS];
CORRECT = CORRECT.split(/\D+/).map(a => Number(a));
totall.push({QUESTION, ANSWERS, CORRECT})
} else ar.push(ANSWERS)
}
return totall
}
document.write(JSON.stringify(createData(data)))
</script>