Javascript: random int between values

  • user warning: Table 'allaboutwebstuff.comments' doesn't exist query: SELECT COUNT(*) FROM comments c WHERE c.nid = 73 AND c.status = 0 in /home/albertoperego/allaboutwebstuff.com/modules/comment/comment.module on line 992.
  • user warning: Table 'allaboutwebstuff.comments' doesn't exist query: SELECT c.cid as cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, c.homepage, u.uid, u.name AS registered_name, u.signature, u.picture, u.data, c.thread, c.status FROM comments c INNER JOIN users u ON c.uid = u.uid WHERE c.nid = 73 AND c.status = 0 ORDER BY c.thread DESC LIMIT 0, 50 in /home/albertoperego/allaboutwebstuff.com/modules/comment/comment.module on line 992.

I just want to share with you a very very simple function wich should be part of the Math library of function but it's not.
I'm talking about a function which returns a random integer between two values.
Here's an easy function which you can use:

function random(min, max)
{
   return Math.round(min + Math.random()*(max - min))
}

That's all for today!

Share and Enjoy: