title: Where to use additional condition when using Array methods
body: <p>I was trying to solve the following question:</p>
  <blockquote>
  <p>Write a function that returns true if all array elements are true. Use reduce</p>
  </blockquote>
  <p>The is the solution I made up</p>
  <pre class="lang-js prettyprint-override"><code>function allTrue(values) {
    if ( values[0] === false) return false
    if (values.length === 0) return true
    let result = values.reduce( (final, value) =&gt; final = value === true, true) 
    return result ? true : false
  }
  </code></pre>
  <p>My question is, whether it is possible to move the external conditions into the reduce method's body or not.</p>
  <p>In other words, if I was required to use a single reduce method to solve it, can I implement it?</p>
  <p>I tried manipulating the <strong>final</strong> in the reduce, but it is modified later in next iterations</p>
  <p>For instance the following test should return <em>false</em> but returns true</p>
  <pre class="lang-js prettyprint-override"><code>allTrue([false, true])
  </code></pre>
  <p>Any explanation would be appreciated, thank you</p>