title: Multiplying array numbers sequentially
body: <p>The best and the easiest way to multiply array numbers sequentially</p>
  <p>I have got an array with some values:</p>
  <pre class="lang-js prettyprint-override"><code>    const arr = [1, 5, 12, 3, 83, 5];
  </code></pre>
  <p>Now I want to get the product of all values from arr. It should works like this: 1 * 5 * 12 * 3 * 83 * 5</p>
  <p>I have tried with this code:</p>
  <pre class="lang-js prettyprint-override"><code>
      const arr = [1, 5, 12, 3, 83, 5];
  
      multiply(arr);
  
      function multiply(arr) {
          for(i = 0; i &lt; arr.length; i++) {
              product = array[i] * array[i];
              console.log(product);
          }
      }
  
  </code></pre>
  <p>This code above works like this: 1 * 1, 5 * 5, 12 * 12, 3 * 3, 83 * 83, 5 * 5 and that is not result that I need. I think I know why it works like this but I'm not sure how to write code that I need.</p>
  <p>So what's the best option for this kind of tasks?</p>
  <p><strong>Edit.
  For non-experienced people looking here in future this is the best option that we've found:</strong></p>
  <p>Leo Martin answer:</p>
  <blockquote>
  <pre><code>    const array = [1, 5, 12, 3, 83, 5];
  
      console.log(multiply(array)); // we log function return value
  
      function multiply(array) {
        let score = array[0];
        for (i = 1; i &lt; array.length; i++) {
          score = score * array[i];
        }
        return score;
      }
  
  </code></pre>
  </blockquote>
  <p>and also the shorter version:</p>
  <blockquote>
  <p>By the way, you could use <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce" rel="nofollow noreferrer"><code>Array.reduce</code></a>:</p>
  <pre><code>
      const array = [1, 5, 12, 3, 83, 5];
  
      const result = array.reduce((acc, value, index) =&gt; {  
        if (index === 0) return value;
        acc = acc * value;
  
        return acc;
      }, 0);
  
      console.log(result);
  
  </code></pre>
  </blockquote>