title: functional programming efficiency vs imperative
body: <p>I'm new to functional programming and I just ran into something and was wondering if there was a way around this.</p>
  
  <p>Suppose I have</p>
  
  <pre><code>myArray = [
    { a : 1 }
    { a : 4 }
    { a : 5 }
    { a : 6 }
    { a : 7 }
    { a : 8 }
  ]
  </code></pre>
  
  <p>Let say I need to do statistical operations on this data set such as</p>
  
  <pre><code>const median = myArray[ Math.ceil( myArray.length / 2 ) ]['a'] // Math.ceil .. Side Effect?
  const fiveOrMore = myArray.filter( value =&gt; value.a &gt;= 5 )
  const lessThanFive = myArray.filter( value =&gt; value.a &lt; 5 )
  </code></pre>
  
  <p>Some arbitrary examples. 
  The problem with this as of right now is that with increasing amount of statistical operations I need to do, the efficiency decreases.</p>
  
  <p>With imperative style, I could do everything in <strong>ONE</strong> for loop. Is this the wrong approach to functional programming that I am taking or is it a <strong>trade off</strong> of functional programming paradigm itself?</p>