How to ordering the the JSON data in a given format using Angular.js/Javascript : I need one help.I need to format some array of data using Angular.js/Javascript.I am explaining the code below.


    var response=[{
          day_id:1,
          day_name:"Monday",
          subcat_id:"2",
          cat_id:"1",
          comment:"hii"
    }, {
          day_id:1,
          day_name:"Monday",
          subcat_id:"1",
          cat_id:"2",
          comment:"hello"
    }
     {
          day_id:2,
          day_name:"Tuesday",
          subcat_id:"3",
          cat_id:"2",
          comment:"hii"
    }
    ]

I have the above given array.I need to convert  it as per following format

    var responseNew = {
          data: [{
            day_name: "Monday",
            day_id:1
            answers:[{
              cat_id:1,
              subcat_id:1,
              comment:'hii'
            },{
              cat_id:1,
              subcat_id:2,
              comment:'hello'
            }]
          }, {
            day_name: "Tuesday",
            day_id:2
            answers:[{
              cat_id:3,
              subcat_id:2,
              comment:'hello'
            }]
          }, {
            day_name: "Wednesday"
             day_id:3
          }, {
            day_name: "Thursday"
             day_id:4
          }, {
            day_name: "Friday"
             day_id:5
          }, {
            day_name: "Saturday",
             day_id:6
          }, {
            day_name: "Sunday"
             day_id:7
          }]
        };


Here i want to convert my first array into the second format.Here one condition is if other day_id is not present its simple set the day name and day id in static as given above.Please help me.
