//random number from 1 to N var random = Math.floor(Math.random() * N + 1); //random number from 1 to 10 //http://www.sharejs.com var random = Math.floor(Math.random() * 10 + 1); //random number from 1 to 100 var random = Math.floor(Math.random() * 100 + 1); //javascript/8780