if condition inside forEach's anonymous function does not work
<p>Consider the code snippet below:</p>

<pre><code>function isUniform(myArray) {
    myArray.forEach(function(element) {
        if (element !== myArray[0]) {
            return false;
        }
    });

    return true;
}
</code></pre>

<p>The intention is that the function should take an array as input and return <code>true</code> if all the elements in the array are the same and <code>false</code> otherwise.</p>

<p>eg:</p>

<p>isUniform([1,2,1,1]); // should return false
isUniform([1,1,1,1]); // should return true</p>

<p>However, the if condition:</p>

<pre><code>if (element !== myArray[0])
</code></pre>

<p>never seem to be true in the case of isUniform([1,2,1,1]).</p>

<p>What is it that I am missing ?</p>