I currently have the following array:
var ExampleArray=[]; //example array Name
ExampleArray.push ({
"No": 1,
"Name": "BB",
"subject": "NS"
},{
"No": 1,
"Name": "BB",
"subject": "PS"
},{
"No": 1,
"Name": "BB",
"subject": "KS"
}
I want to turn that array into the following array (with a nested object).
var array = {
"No": 1,
"Name": "BB",
"subject":
{
["NS","SS","KS"]
}
}
How do I do this?
Array.prototype.reduce()
is your best friend. – Redu Jan 3 at 19:42