Skip to content

Instantly share code, notes, and snippets.

@finscn
Created February 20, 2013 03:27
Show Gist options
  • Save finscn/4992622 to your computer and use it in GitHub Desktop.
Save finscn/4992622 to your computer and use it in GitHub Desktop.
function randomPick(list){
return list[ Math.random()*list.length|0 ];
}
function test(listSize,testCount){
listSize = listSize||20;
testCount = testCount||100;
var list=[ ];
for (var i=0;i<20;i++){
list.push("a_"+i);
}
var rs=[]
for (var i=0;i<100;i++){
rs.push(randomPick(list));
}
rs.sort();
for (var i=0;i<rs.length;i++){
console.log(rs[i]);
}
}
test();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment