simple underscore.js projects, walk through, & tutorial


Lottery DataBase Analysis - 05 (_.zip, _.pluck)


California Lucky for Life (832)
Prizes Odds 1 in Total # of Winners Prizes Claimed Prizes Available
$3,250,000 2,400,000 17 11 6
$5,000 1,200,000 34 22 12
$1,000 400,000 102 65 37
$500 12,000 3,400 2,239 1,161
$100 645 63,240 41,624 21,616
$40 350 116,620 76,812 39,808
$20 53 765,000 498,167 266,833
$15 40 1,020,000 668,467 351,533
$10 20 2,040,000 1,325,571 714,429
$5 11 3,570,000 2,287,131 1,282,869
Ticket 10 4,080,000 2,524,475 1,555,525



    // odds
    var odds = _.pluck(game832Data, "Odds 1 in");
    odds = _.map(odds, function(n){return parseInt(n.replace(/,/g,""),10);});
    document.getElementById('outputOne').innerHTML = _.map(odds, function(n){return ' ' + n;});

var odds =:
1 Nada Yet



    // numWins
    var numWin = _.pluck(game832Data, "Total # of Winners");
    numWin = _.map(numWin, function(n){return parseInt(n.replace(/,/g,""),10);});
    document.getElementById('outputTwo').innerHTML = _.map(numWin, function(n){return ' ' + n;});

var numWins =:
2 Nada Yet



    // newArray zip
    var oddWinSubData = _.zip(odds, numWin);
    document.getElementById('outputThree').innerHTML = _.map(oddWinSubData, function(n){return ' ' + n;});

oddWinSubData zip array =:
3 Nada Yet



    // odds * # Winners
    var totalPlays = _.map(oddWinSubData,
        function(passedArray){
            return passedArray[0] * passedArray[1];
        });
    document.getElementById('outputFour').innerHTML = _.map(totalPlays, function(n){return ' ' + n;});

Odds * # Winners = 
4 Nada Yet



    // Working Value -- Total # of Tickets in Game
    var ticketsInGame = totalPlays[0];
    document.getElementById('outputFive').innerHTML = ticketsInGame;

Total Number of Tickets in Game
5 Nada Yet




_.moreUnderscoreProjects

© Copyright 2013 Brett Paufler



Please Note: I am an idiot.  No seriously.  The odds of my gambling odds calculations being correct are likely on par with my odds of ever winning.  You have been warned.