title: How to use reduce() instead a traditional foreach loop with ReactJs app
body: <p>I have the following code on my React app:</p>
  
  <pre><code>var numberOfAnswers = 0
  var sumOfAnswers = 0
  
  respostas.forEach(function (element,index) {
      console.log(index+"-"+element["responses"])
      numberOfAnswers += element["responses"]
      sumOfAnswers += (index*element["responses"])                
  })
  </code></pre>
  
  <p>it works perfectly, but I want to use something like that:</p>
  
  <pre><code>const arrSum = respostas =&gt; respostas.reduce((a,b) =&gt; a + b, 0)
  </code></pre>
  
  <p>Is it possible to do that using reduce() and if it is possible, how can I do that?</p>