by Stian

How to do a raffle ticket draw in javascript

I would like your help on how to do a raffle ticket draw using JavaScript. I am throwing out a suggestion and  hope that you will try to improve or accept this code by using the comment field below (that is if you are human enough to beat the captcha!)

function Draw(){
    var tickets=["Andreas","Andreas","Andreas","Andreas","Andreas","Andreas",
    "Andreas","Andreas","Andreas","Andreas","Andreas","Andreas",
    "Thor Halvor","Thor Halvor","Thor Halvor","Thor Halvor","Thor Halvor",
    "Thor Halvor","Thor Halvor","Thor Halvor","Thor Halvor","Njål","Njål",
    "Njål","Njål","Aage","Aage","Aage", "Stian", "Stian", "Stian","Stian","Joakim"];

    var winner = Math.floor(Math.random()*tickets.length);
    alert("The winner is: " + tickets[winner]);
}


I would recommend using a website like http://jsbin.com to write up and test your script

  • thorhalvor

    I only trust the good old “pulling the name out of the hat” way :)

    Had to click 8-9 times before I won with your script. Bet I will be one of three when using the hat. I just feelt it.