title: React - how to show array length from result of the other array process
body: <p>I want to show array length from result of the other array process.
  I have one array contain 3 objects and want to get the failed result property length.</p>
  
  <p>Code :</p>
  
  <pre><code>import React, { Component } from 'react';
  
  class App extends Component {
      constructor(props) {
          super(props);
  
          this.state = {
              arrays: []         
          };
      }
  
      componentDidMount () {
          this.getData();
      }
  
      getData = () =&gt; {
          const arrays = [
              {
                  name: 'one',
                  value: '1',
                  result: 'failed'
              },
              {
                  name: 'two',
                  value: '2',
                  result: 'success'
              },
              {
                  name: 'three',
                  value: '3',
                  result: 'failed'
              }
          ];
          this.setState({
              arrays : arrays
          })
      }
  
      render() {
          const { arrays } = this.state;
          console.log(arrays);
          console.log('arrays length: ' + arrays.length);
  
          const fArray = [];
          console.log(fArray);
          console.log('fArray length: ' + fArray.length);
  
          return (
              &lt;div className='App'&gt;
                  {arrays.map(function(array) {                    
                      if (array.result === 'failed') {
                          const failed = {
                              fName: array.name,
                              fValue: array.value,
                              fResult: array.result
                          }
                          fArray.push(failed);
                      }
                      return null;
                  })}
              &lt;/div&gt;
          );
      }
  }
  
  export default App;
  </code></pre>
  
  <p>console result :</p>
  
  <p><a href="https://i.stack.imgur.com/n9vWF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/n9vWF.png" alt="enter image description here"></a></p>
  
  <p>At the picture above why the first <code>arrays</code> and <code>fArray</code> show 0 length?</p>
  
  <p>The second <code>arrays</code> shows 3 length and <code>fArray</code> shows 0, but it have two failed results. </p>
  
  <p>I mean, can i get the two failed results length from <code>fArray</code>?</p>
  
  <p>Please tell me if my post is duplicate.</p>