title: How to create JSON in Javascript with a variable?
body: <p>I have code that returns an array in json format but I want it to be under &quot;data&quot;:
  So right now, it shows as:</p>
  <p><code> &quot;[&quot;newDate&quot;: 'test'&quot;: 'test',&quot;attendees&quot;: 'test,&quot;name&quot;: 'Foo']&quot;</code></p>
  <p>How do I get it as: <code> &quot;{ data: [&quot;newDate&quot;: 'test'&quot;: 'test',&quot;attendees&quot;: 'test,&quot;name&quot;: 'Foo'] }&quot;</code></p>
  <pre><code>let countries = [];
      for (x in newObj) {
          countries.push({
              &quot;newDate&quot;: newObj[x][0],
              &quot;count&quot;: getDates()[x].length,
              &quot;attendees&quot;: getDates()[x],
              &quot;name&quot;: x
          })
      }
  return JSON.stringify(countries);
  </code></pre>