Return specific elements in array with .filter?
<p>I'm trying to learn some functional programming principles in javascript, but having some issues. I understand the iterative method (just a for loop), but I wanted to know if there was a functional programming style solution.</p>

<p>Say we have an array <code>A</code> where each element of <code>A</code> is another array, let's call these elements <code>a</code>:</p>

<pre><code>A: [ Array[28], Array[28], ... ], where a_1..a_n is an array of size 28
</code></pre>

<p>Now say I only want the <code>5th element</code> within <code>a</code> (so <code>a[4]</code>). </p>

<p>How would I do that using one of the higher order functions such as <code>.map, .filter</code> etc? </p>

<p>I've tried a method as such:</p>

<pre><code>function myMethodThatReturns5thElem(n) {
 return n[4];
}

var arrayThatHas5thElements = A.filter(myMethodThatReturns5thElem);
</code></pre>

<p>but then <code>arrayThatHas5thElements</code>is the same exact array as <code>A</code>..</p>

<p>Hopefully this makes sense.</p>

<p>Thank you.</p>