Last active
August 29, 2015 14:03
-
-
Save qwo/9de443b149c7ab37573a to your computer and use it in GitHub Desktop.
Meetup Raffle Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//pass in number of winners | |
//todo UNIQUE winners and prize mapping | |
var pickWinners = function(numberOfWinners){ | |
var meetup = $(".member-name"); | |
var winners = []; | |
var picked_numbers = {}; | |
while (numberOfWinners){ | |
var winner = Math.floor(Math.random() * meetup.length); | |
////bug in duplciates ins winners array | |
if(winners.indexOf($(meetup[winner]).text().trim()) < 0 ){ | |
winners.push($(meetup[winner]).text().trim()); | |
numberOfWinners = numberOfWinners - 1; | |
} | |
} | |
//generate winner/s | |
return winners | |
} | |
//pickWinners(5) |
fixed errors works 100% now.
clippers(generateWinners(5))
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
updated to make robust