Add neighboring stones of the same color to form chains, with logging for isolated stones I'm trying to check four things, one of those things might happen, maybe two, three or four things, but if none of them occur, then I want to run some code. I can't do an else statement because that only applies to one and I can't do else if because more than one can happen. 

At the moment I've resorted to this:

function checkChains(x, y, color, array)
{
    var count = 0;

    if ((x + 1) != (boardSize) &amp;&amp; (stones[x + 1][y] == color))
    {
        addToChain(x, y, x + 1, y, array);
    }
    else
    {
        count++;
    }

    if ((x != 0) &amp;&amp; (stones[x - 1][y] == color))
    {
        addToChain(x, y, x - 1, y, array);
    }
    else
    {
        count++;
    }

    if ((y + 1) != (boardSize) &amp;&amp; (stones[x][y + 1] == color))
    {
        addToChain(x, y, x, y + 1, array);
    }
        else
    {
        count++;
    }

    if ((y != 0) &amp;&amp; (stones[x][y - 1] == color))
    {
        addToChain(x, y, x, y - 1, array);
    }
    else
    {
        count++;
    }

    if (count == 4)
    {
        console.log("none!");
    }
}


It's pretty ugly, can this be tidied?
You don't really need your elses. Move count++ to the if, and change your last if to !count.
Rather than using !=, you should really use &lt; and &lt;=. This means you you can use x + 1 &lt; boardSize rather than (x + 1) != (boardSize).
You should learn operator precedence, == happens before &amp;&amp;. And so you can remove even more parentheses.


And so you can use:

function checkChains(x, y, color, array)
{
    var count = 0;

    if (x + 1 &lt; boardSize &amp;&amp; stones[x + 1][y] == color)
    {
        addToChain(x, y, x + 1, y, array);
        count++;
    }

    if (x &gt; 0 &amp;&amp; stones[x - 1][y] == color)
    {
        addToChain(x, y, x - 1, y, array);
        count++;
    }

    if (y + 1 &lt; boardSize &amp;&amp; stones[x][y + 1] == color)
    {
        addToChain(x, y, x, y + 1, array);
        count++;
    }

    if (y &gt; 0 &amp;&amp; stones[x][y - 1] == color)
    {
        addToChain(x, y, x, y - 1, array);
        count++;
    }

    if (!count)
    {
        console.log("none!");
    }
}