Name Mon Lu

Love jQuery/CSS

Blog about Webdev

Twitter supawaza

RSS Twitter Flickr

What I am up to:


Quickie note, a very sim­ple script to pick a ran­dom num­ber between 1–5, instead of 0–4

	var rand = Math.floor(Math.random()*5);
	if(rand > 0){
		rand = rand+1;
		alert(rand);
	} else {
		rand = 1;
		alert(rand);
	}

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • email
  • Ping.fm
  • Reddit
  • RSS
  • StumbleUpon
  • Technorati
  • Twitter

Related Posts

No related posts.

This entry was posted on Friday, August 14th, 2009 at 1:11 PM and is filed under Web Dev. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

No Responses to “Javascript: Pick a random number starting from 1”