title: RXJS loop through items and return an array
body: <p>My service called "<strong>getList</strong>" returns a list of items.
  I want to loop through the list of items and format the date.
  Then return the formatted array.</p>
  
  <p>My current attempt doesnt return the items in the array because I use flatMap in order to loop the items in map. </p>
  
  <p>I'm using angular6 and rxjs.</p>
  
  <p><strong>My attempt:</strong></p>
  
  <pre><code>this.list$ = this.service.getList()
        .pipe(
          flatMap(response =&gt; response.items),
          map(item =&gt; {
            item.date = moment(item.date).format('YYYY-MM-DD').toString();
            return item;
          })
        );
  </code></pre>