Making a function that adds numbers in an array and returns their sum in javascript
<p>I'm trying to create a function that will add the numbers in an array and return their sum. For some reason it's returning 1 instead of 15 and I'm not sure why.</p>

<pre><code>var myArray = [1,2,3,4,5];  
function addThemUp(myArray) {
    var arrayTotal = myArray.length; 
    var totalSum = 0;

    for(var x = 0; x &lt;arrayTotal; x++) {
        totalSum += myArray[x];
        return(totalSum)
    }
}

addThemUp(myArray)
</code></pre>