title: how to build json array dynamically in javascript
body: <p>I receive a json object with some number of quick reply elements from wit.ai, like this: </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code> "msg": "So glad to have you back.  What do you want me to do?  
   "action_id": "6fd7f2bd-db67-46d2-8742-ec160d9261c1",
   "confidence": 0.08098269709064443,
   "quickreplies": [
     "News?",
     "Subscribe?",
     "Contribute?",
     "Organize?"
   ],
   "type": "msg"</code></pre>
  </div>
  </div>
  </p>
  
  <p>I then need to convert them to a slightly different format as they are passed to FaceBook Messenger as described in the code below.  Wit only exposes 'msg' and 'quickreplies.' Can you suggest a good way to do this?  It goes after "console.log(element)" as far as I understand.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>      if (quickreplies){
          // got simple array of quickreplies
          // need to format quickreplies for FB:
                                    //  "quick_replies":[
                                    //     {
                                    //       "content_type":"text",
                                    //       "title":"Red",
                                    //       "payload":"DEVELOPER_DEFINED_PAYLOAD_FOR_PICKING_RED"
                                    //     },
                                    //     {
                                    //       "content_type":"text",
                                    //       "title":"Green",
                                    //       "payload":"DEVELOPER_DEFINED_PAYLOAD_FOR_PICKING_GREEN"
                                    //     }
          console.log('we got quickreplies, here they are:');
          var quick_replies = []; // ??
          quickreplies.forEach(function(element) {
            console.log(element)
  
          });
        }
        else (console.log('no quickreplies'));                               </code></pre>
  </div>
  </div>
  </p>
  
  <p>In the above example, the end result should be this:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code> "recipient":{
      "id":"USER_ID"
    },
    "message":{
      "text":"Pick a color:",
      "quick_replies":[
        {
          "content_type":"text",
          "title":"Red",
          "payload":"DEVELOPER_DEFINED_PAYLOAD_FOR_PICKING_RED"
        },
        {
          "content_type":"text",
          "title":"Green",
          "payload":"DEVELOPER_DEFINED_PAYLOAD_FOR_PICKING_GREEN"
        }
      ]
    }</code></pre>
  </div>
  </div>
  </p>