|
JavaScript Tips Buy this website for $5000 USD Priced to sell, this is an established JavaScript website, growing in popularity as evidenced by its Alex ranking. Includes most website content. The price is NON-NEGOTIABLE. Serious buyers should contactCreating Random Numbers The Math.random() method in JavaScript is used to create a random number. This method returns a floating point number within the range of 0 to 1. To convert the result to an integer, you could use the Math.average() method. The following method below, createRandomNumber() can be used to create random numbers from 0 to the parameter specified by maxInt function createRandomNumber(maxInt){ return Math.round(Math.random() * maxInt); } createRandomNumber(1); //Returns a random number which is either 0 or 1 createRandomNumber(5); //Returns a random number from 0 to 5 |