title: How can I concatenate this type of JSON in javascript?
body: <p>How can I concatenate this json to obtain it:</p>
  <p><code>complements = [&quot;XYZ 3, CDE TR, AAA 5&quot;, &quot;&quot;, &quot;NDP 3, DDD FR&quot;]</code> ?</p>
  <p>Each address can contain a set of complements which must be concatenated and separated by a comma.</p>
  <p>P.s: I'm using javascript.
  P.s2: Complements can be null like in the second group in JSON.</p>
  <pre><code>[
      {
          &quot;postalcode&quot;: &quot;1234&quot;,
          &quot;street&quot;: &quot;ABC&quot;,
          &quot;number&quot;: &quot;1&quot;,
          &quot;complement&quot;: [
              {
                  &quot;type&quot;: &quot;B&quot;,
                  &quot;name&quot;: &quot;XYZ&quot;,
                  &quot;description&quot;: &quot;3&quot;
              },
              {
                  &quot;type&quot;: &quot;C&quot;,
                  &quot;name&quot;: &quot;CDE&quot;,
                  &quot;description&quot;: &quot;TR&quot;
              },
              {
                  &quot;type&quot;: &quot;D&quot;,
                  &quot;name&quot;: &quot;AAA&quot;,
                  &quot;description&quot;: &quot;5&quot;
              }
          ]
      },
   {
          &quot;postalcode&quot;: &quot;444&quot;,
          &quot;street&quot;: &quot;No complements&quot;,
          &quot;number&quot;: &quot;5&quot;
      },
      {
          &quot;postalcode&quot;: &quot;2222&quot;,
          &quot;street&quot;: &quot;BBB&quot;,
          &quot;number&quot;: &quot;2&quot;,
          &quot;complement&quot;: [
              {
                  &quot;type&quot;: &quot;E&quot;,
                  &quot;name&quot;: &quot;NDP&quot;,
                  &quot;description&quot;: &quot;3&quot;
              },
              {
                  &quot;type&quot;: &quot;F&quot;,
                  &quot;name&quot;: &quot;DDD&quot;,
                  &quot;description&quot;: &quot;FR&quot;
              }
          ]
      }
  ];
  
  </code></pre>
  <p><strong>My code</strong> I'm getting <em>this.complementsList.forEach is not a function</em>.</p>
  <pre><code>getComplement(addressesResponse){
      this.complementsList = JSON.parse(addressesResponse);
  
      this.complementsList.forEach((item) =&gt; {
      Object.defineProperty(item, 'complements', {
          get: function() { 
              return this.complement.map((c) =&gt; `${c.name} ${c.description}`).join(', '); }
      })
  });
  
  </code></pre>
  <p>Source: <a href="https://salesforce.stackexchange.com/questions/367713/how-to-render-a-json-in-the-same-line-lwc">https://salesforce.stackexchange.com/questions/367713/how-to-render-a-json-in-the-same-line-lwc</a></p>