JavaScript Tic Tac Toe - functional but could be DRYer I've been working on a simple Tic Tac Toe game in JavaScript.  It runs the way it should, but the Board.checkWin function (check every possible winning combo) could be better, it is very repetitive in its current state.  Any ideas?

Here is my Cell class:

var Cell = function() {
this.value = "|_|";
};

Cell.prototype.setState = function(arg) {
    this.value = arg;
};

Cell.prototype.playable = function() {
    if (this.value == "|_|") {
        return true;
    } else {
        return false;
    }
};

Cell.prototype.render = function() {
    return this.value;
};


Here is my Board class:

var Board = function() {
    this.cells = [];
    this.currentPlayers = ["|X|","|O|","|X|","|O|","|X|","|O|","|X|", "|O|", "|X|"]; 
    this.winner = this.currentPlayers[1];
};

Board.prototype.startGame = function() {
    for (i = 0; i &lt; 9; i++) {
        this.cells.push(new Cell);
    }
    return this.render();
};

Board.prototype.makePlay = function(position) {
    if (this.checkWin() == false) {

    if (position &lt; this.cells.length) {
        var cell = this.cells[position];
        var currentPlayer = this.currentPlayers.shift();

        if (cell.playable() == true) {
        cell.setState(currentPlayer);
        }
    }   
    return this.render();
    }
};

Board.prototype.checkWin = function() {

for(var i = 0; i &lt; this.cells.length; i++)
    if (this.cells[0].value == "|X|" &amp;&amp; this.cells[1].value == "|X|" &amp;&amp; this.cells[2].value == "|X|"    ||
        this.cells[0].value == "|O|" &amp;&amp; this.cells[1].value == "|O|" &amp;&amp; this.cells[2].value == "|O|" ||

        this.cells[3].value == "|X|" &amp;&amp; this.cells[4].value == "|X|" &amp;&amp; this.cells[5].value == "|X|" || 
        this.cells[3].value == "|O|" &amp;&amp; this.cells[4].value == "|O|" &amp;&amp; this.cells[5].value == "|O|" || 

        this.cells[6].value == "|X|" &amp;&amp; this.cells[7].value == "|X|" &amp;&amp; this.cells[8].value == "|X|" ||
        this.cells[6].value == "|O|" &amp;&amp; this.cells[7].value == "|O|" &amp;&amp; this.cells[8].value == "|O|" || 

        this.cells[0].value == "|X|" &amp;&amp; this.cells[3].value == "|X|" &amp;&amp; this.cells[6].value == "|X|" || 
        this.cells[0].value == "|O|" &amp;&amp; this.cells[3].value == "|O|" &amp;&amp; this.cells[6].value == "|O|" || 

        this.cells[1].value == "|X|" &amp;&amp; this.cells[4].value == "|X|" &amp;&amp; this.cells[7].value == "|X|" || 
        this.cells[1].value == "|O|" &amp;&amp; this.cells[4].value == "|O|" &amp;&amp; this.cells[7].value == "|O|" || 

        this.cells[2].value == "|X|" &amp;&amp; this.cells[6].value == "|X|" &amp;&amp; this.cells[8].value == "|X|" || 
        this.cells[2].value == "|O|" &amp;&amp; this.cells[6].value == "|O|" &amp;&amp; this.cells[8].value == "|O|" || 

        this.cells[0].value == "|X|" &amp;&amp; this.cells[4].value == "|X|" &amp;&amp; this.cells[8].value == "|X|" || 
        this.cells[0].value == "|O|" &amp;&amp; this.cells[4].value == "|O|" &amp;&amp; this.cells[8].value == "|O|" || 

        this.cells[6].value == "|X|" &amp;&amp; this.cells[4].value == "|X|" &amp;&amp; this.cells[2].value == "|X|" || 
        this.cells[6].value == "|O|" &amp;&amp; this.cells[4].value == "|O|" &amp;&amp; this.cells[2].value == "|O|")

        {
            return true;
        } else {
            return false;
    }
};

Board.prototype.render = function() {
    var boardArray = [];
    for (var i = 0; i &lt; this.cells.length; i++) {
        boardArray.push(this.cells[i].value);
    }
    for (var j = 0; j &lt; boardArray.length; j++) {
        var boardString = "TIC TAC TOE " + boardArray[0] + boardArray[1] + boardArray[2] + "\n ";
        boardString += " PICK A BOX " + boardArray[3] + boardArray[4] + boardArray[5] + " \n ";
        boardString += "   0 THRU 8 " + boardArray[6] + boardArray[7] + boardArray[8];
    }

    if (this.checkWin() == true) {
        return boardString + "\n   WE HAVE A WINNER!";
    } else {
    return boardString;     
    }
};
The most un-DRY code is checking if someone has won. You could add the following code to help you

// Row class

var Row = function{
    this.cells = [];
}

Row.prototype.allSame = function(){
    return this.cells[0] == this.cells[1] &amp;&amp; this.cells[0] == this.cells[1];
}

// Expand the Board class
Board.prototype.getRow = function(num) {
    var row = new Row();

    // Horizontal rows
    if (num =&gt; 0 &amp;&amp; num &lt; 3) {
        row.cells.push(this.cells[3*num], this.cells[(3*num)+1], this.cells[(3*num)+2]);
        return row;
    }

    // Vertical rows
    if (num =&gt; 3 &amp;&amp; num &lt; 6) {
        row.cells.push(this.cells[num-3], this.cells[(num], this.cells[num+3]);
        return row;
    }

    // Diagonal rows
    if (num == 6) {
        row.cells.push(this.cells[0], this.cells[(5], this.cells[8]);
        return row;
    }

    if (num == 7) {
        row.cells.push(this.cells[2], this.cells[(5], this.cells[6]);
        return row;
    }

    return false;

};


Running on the assumtions that the first 3 horizontal rows are numbered from 0 to 2, the 3 columns from 3 to 5 and the 2 diagonals 6 and 7...

But I am not sure the amount of code you would save would be enough to make the change worth it, unless you are predicting adding bigger boards, beyond the classic 3x3.