I came up with something pretty similar while generating items. However, the following code gets pretty hard to read with lots of items because the values don't line up. And while balancing, you will want to be able to read and modify it <i>very easily</i>:<p>>var list = ['javascript', 'php', 'ruby', 'python'];
var weight = [0.5, 0.2, 0.2, 0.1];<p>You could instead put each into an object: {
language: 'javascript',
weight: 0.5
}<p>My code (in the itemRoll function) demonstrates this, but it is a little bit more rolled out because I was instantiating objects: <a href="http://humbit.com/rogue/afsahr-v1.2/js/inventory.js" rel="nofollow">http://humbit.com/rogue/afsahr-v1.2/js/inventory.js</a>