|
Help
CodingForums Partners
This is a
![]() |
Generating a random number in JavaScript
A popular question on
CodingForums.com is
how to generate a random number in JavaScript. A random number is useful- if
not required- in the creation of certain popular JS applications, such as a
dice, random image script, or random link generator. In this JavaScript
article, we'll learn how to output a random number that falls within the
range 1 to x, where x is any integer >1. var randomnumber=Math.floor(Math.random()*11) where 11 dictates that the random number will fall between 0-10. To increase
the range to, say, 100, simply change 11 to 101 instead. |