title: How to merge objects into one string
body: <p>Say i have an object like this</p>
  <pre><code>```
  {
    &quot;ListOfStudents&quot;: {
      &quot;-LTzCztVLA0PW-duF-3e&quot;: {
        &quot;StudentInfo&quot;: {
          &quot;csvTestFile&quot;: {
            &quot;2018-12-18&quot;: {
              &quot;attendanceDate&quot;: &quot;2018-12-18&quot;,
              &quot;attendanceStatus&quot;: &quot;present&quot;
            },
            &quot;2018-12-19&quot;: {
              &quot;attendanceDate&quot;: &quot;2018-12-19&quot;,
              &quot;attendanceStatus&quot;: &quot;absent&quot;
            },
            &quot;2018-12-20&quot;: {
              &quot;attendanceDate&quot;: &quot;2018-12-20&quot;,
              &quot;attendanceStatus&quot;: &quot;present&quot;
            }
          }
        }
      },
      &quot;-LTz15VLA0PW-duF-123&quot;: {
        &quot;StudentInfo&quot;: {
          &quot;csvTestFile&quot;: {
            &quot;2018-12-18&quot;: {
              &quot;attendanceDate&quot;: &quot;2018-12-18&quot;,
              &quot;attendanceStatus&quot;: &quot;present&quot;
            },
            &quot;2018-12-19&quot;: {
              &quot;attendanceDate&quot;: &quot;2018-12-19&quot;,
              &quot;attendanceStatus&quot;: &quot;absent&quot;
            },
            &quot;2018-12-20&quot;: {
              &quot;attendanceDate&quot;: &quot;2018-12-20&quot;,
              &quot;attendanceStatus&quot;: &quot;absent&quot;
            }
          }
        }
      },
      &quot;-LTz15VL515W-duF-163&quot;: {
        &quot;StudentInfo&quot;: {
          &quot;csvTestFile&quot;: {
            &quot;2018-12-18&quot;: {
              &quot;attendanceDate&quot;: &quot;2018-12-18&quot;,
              &quot;attendanceStatus&quot;: &quot;absent&quot;
            },
            &quot;2018-12-19&quot;: {
              &quot;attendanceDate&quot;: &quot;2018-12-19&quot;,
              &quot;attendanceStatus&quot;: &quot;absent&quot;
            },
            &quot;2018-12-20&quot;: {
              &quot;attendanceDate&quot;: &quot;2018-12-20&quot;,
              &quot;attendanceStatus&quot;: &quot;absent&quot;
            }
          }
        }
      }
    }
  }
  ```
  </code></pre>
  <p><em><strong>Here's my code</strong></em></p>
  <pre><code>const names = 'Albert,John,Alex';
  
  saveCSVFile(data) {
  const { classUID } = data;
  const { currentUser } = firebase.auth();
  
  const student = [];
  
  firebase
    .database()
    .ref(`/users/${currentUser.uid}/ClassAttendance/${classUID}/ListOfStudents`)
    .on('value', snapshot1 =&gt; {
      snapshot1.forEach(child =&gt; {
        student.push(child.val().StudentInfo);
  
        const keys = Object.keys(child.val().StudentInfo.csvTestFile);
        const dates = keys.map(key =&gt; child.val().StudentInfo.csvTestFile[key]);
        console.log(dates);
      });
    });
  }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/alKvR.png" rel="nofollow noreferrer">Here's the console log output</a></p>
  <p>What i wanted is to merge <strong>'attendanceStatus'</strong> into one string but for every first object i want to put each names in the string, and for every last object i want to put <strong>'\n'</strong> on it and a <strong>,</strong> (comma) for each attendanceStatus.</p>
  <p>Expected Final Output in String:</p>
  <blockquote>
  <p>'Albert,present,absent,present\n</p>
  <p>John,present,absent,absent\n</p>
  <p>Alex,absent,absent,absent\n'</p>
  </blockquote>
  <p>or may be the output would be like this</p>
  <blockquote>
  <p>'Albert,present,absent,present\nJohn,present,absent,absent\nAlex,absent,absent,absent\n'</p>
  </blockquote>
  <p>I have been thinking on how to do this for a week, but no luck. Please help</p>