Quotes help make search much faster. Example: "Practice Makes Perfect"

Wednesday, November 7, 2012

Codecademy: Sample Solution for setUpPieces() function in "Build a Checkers Board"



function setUpPieces() {
    //select all the divs with class 'piece'
    //add the 'light' class to half of them
    //add the 'dark' to the other half
   
    var $evenCheckerPieces = $('div:even').filter('.piece');
    var $oddCheckerPieces = $('div:odd').filter('.piece');
    var pieceCount = 12;
    for (var i=0;i<pieceCount;i++) {
        $evenCheckerPieces.addClass('light');
    $oddCheckerPieces.addClass('dark');
    }
}

//note: further code exists beyond this line

No comments:

Post a Comment


This is an example of scrolling text using Javascript.

Popular Posts