How to see if two image sources are equal?
<p>I am trying to see if two images that the user clicked on are the same.
I have some code that retrieves the source of an image that was clicked on:</p>

<p><code>$('img').click(function() {
        var path = $(this).attr('src');
    });</code></p>

<p>I just need a way to compare two sources with each other.
I tried storing the sources in an array and seeing if they were equal but I couldn't get that to work:</p>

<pre><code>var bothPaths = [];

$('img').click(function() {
    var path = $(this).attr('src');
    bothPaths.push(path);
}); 

if (bothPaths[0] == bothPaths[1]) {
    alert("they match.");
} else {
    alert("they don't match.");
}
</code></pre>

<p>I would assume that this would compare the first two image sources that the user clicked on but I seem to have a problem somewhere.</p>
