TheIronYard--Orlando / FEE--2014--FALL

The Handbook for the Front End Engineering class of the Fall 2014 cohort at The Iron Yard, Orlando Campus
Creative Commons Zero v1.0 Universal
14 stars 13 forks source link

12-All-the-World-an-Object.md Jon Manock #177

Closed jmanock closed 10 years ago

jmanock commented 10 years ago

Resources:

New Concepts:

function toEnglish(value){ /* . . . */ }
// turn ^^ into vv
var CheckWriting = {
    toEnglish: function(value){ /* . . . */ }
}

Project Euler Format

/* === PRODUCTION CODE === */
function solution(){
    // change input to suit the solution, e.g. `limit`
    return {
        // I wanna see this one...
        solveFor: function(limit){ /* perform magic... */ },

        // For Problem 2, for example... However you solve it.
        fibonacci: function(limit){ /* . . . */ },
        filterEvens: function(list){ /* . . . */ },
        sum: function(list){ /* . . . */ }
    }
}

/* === TEST CODE === */
// You should probably write some...

Conway's Game of Life

var game = {
    board: undefined,
    newBoard: function(){ /* i.e. board() */ },
    rules: function(cell, neighbors){ /* i.e. conway(cell, neighbors) */ },
    neighborsOf: function(x,y){ /* . . . */ },
    tick: function(){ /* accepts nothing, alters `game.board` */ },

    /**
     * WARNING: This is VOODOO MAGIC...
     *
     * GIVEN:
     *   this.board === [
     *      [ false, true,  false ],
     *      [ false, true,  false ],
     *      [ false, true,  false ],
     *   ];
     *
     * EXPECT:
     *   +---+---+---+
     *   |   | X |   |
     *   +---+---+---+
     *   |   | X |   |
     *   +---+---+---+
     *   |   | X |   |
     *   +---+---+---+
     */
    display: function(){
        var spacer = '+---+---+---+\n';

        return spacer +
            // Apply `renderRow` to each `row` in `board`...
            this.board.map(function renderRow(row){
                return '| ' +
                    // Apply `renderCell` to each `cell` in `row`...
                    row.map(function renderCell(cell){
                        // return 'X' if `cell` is TRUTHY otherwise return ' '
                        return cell && 'X' || ' ';
                    }).join(' | ') // Place ' | ' between each `cell`...
                + ' |\n';
            }).join(spacer) // Place `spacer` between each `row`...
        + spacer;
    } // END display
} // END game
bgates commented 10 years ago

no PR