Random generation for JavaScript with Chance

Chance, by Victor Quinn, is a small (~18k) JavaScript library that makes random generation dead simple! You can generate random numbers, strings, addresses, dice, and more. Usage is simple:

<script src="chance.js"></script>
<script>
  var my_chance = new Chance();
  console.log(my_chance.bool()); // either true or false
  console.log(my_chance.phone()); // (xxx) xxx-xxxx
  console.log(my_chance.paragraph({sentences: 1})); // random paragraph with one sentence
  console.log(my_chance.sentence({words: 5})); // random sentence with five words
</script>

There are a ton of options, and you can view them all at the chance website, or view the source at GitHub.

News Films

Our little film studio focuses on telling developer-centric stories that need to be seen.

Beyond Code: Season 3 / GopherCon 2015

 
0:00 / 0:00