finding Middle element of an array in javascript
<p>I need to write a program that finds the middle of an array and returns the value stored there unless the array is even then it should return the average of the two middle most numbers. Here is the code i have so far. i'm stuck on how i would find the middle two numbers in an even array and return the average. I'm a super beginner in java script so all help is appreciated. Thanks!</p>

<p><div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE HTML&gt;
&lt;html lang="en-us"&gt;
&lt;head&gt;
&lt;meta charset="utf-8"&gt;
&lt;title&gt;Add Ends&lt;/title&gt;
    &lt;script language="javascript" type="text/javascript"&gt;
      /*
      Write a function named getMiddle that returns the value of the middle element in an array. If the array has an even number of elements, then this function must return the average of the two middle elements.
      */
        var testNumbers = [0, 1 ,2, 3, 4, 5, 6, 7, 8, 9]


       function isEven()
        {
        var mid = (testNumbers[0] + (testNumbers.length)) / 2;   
        }
        
        function getMiddle(list) 
        {
            var mid = (testNumbers[0] + (testNumbers.length)) / 2;
            if (mid % 2 == 0)
                {
                var evenMid = isEven();
                document.getElementById("outputDiv1").innerHTML = evenMid;
                }
            else 
                {
                document.getElementById("outputDiv1").innerHTML = mid;
                }
        }

    &lt;/script&gt;   
&lt;/head&gt;

&lt;body&gt;
        &lt;button type="button" onclick="binarySearch()"&gt;Find the Middle&lt;/button&gt;
        &lt;br&gt;
        &lt;div id="outputDiv1"&gt;&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;     </code></pre>
</div>
</div>
</p>