Linked Questions

89 votes
2 answers
118k views

I am trying to generate random 0 or 1 as I am writing a script to populdate my database. If it is 1, I will save it as male and 0 the other way around. Inside my JavaScript: Math.floor((Math.random()...
user avatar
78 votes
3 answers
120k views

I need to create a random number between 0.0200 and 0.120 using JavaScript. How would I do this? I specifically am interested in floating point numbers, not whole numbers. The question linked (...
danieljames's user avatar
30 votes
4 answers
62k views

Possible Duplicate: Generating random numbers in Javascript How do I get a random number between −10 and 10 in JavaScript?
coure2011's user avatar
  • 42.8k
29 votes
3 answers
55k views

Possible Duplicate: Generating random numbers in Javascript in a specific range? How can i get a random value between, for example, from -99 to 99, excluding 0?
18 votes
2 answers
39k views

Possible Duplicate: Generating random numbers in Javascript I have the following code var randomnumber=Math.floor(Math.random()*101); that generates a random number for me between 1 and 100. What ...
13 votes
5 answers
26k views

Possible Duplicate: Generating random whole numbers in JavaScript in a specific range How can I get one-digit random numbers (1, 2, 3, ..., not 0.1, 0.2, ... or 1.0, 5.0, ...) using Math.random() or ...
7 votes
1 answer
15k views

I am trying to create fake IP address using the following javascript random method. But not works. any one help me to get the correct way to do this? here is my try: I am looking like ( "192.168.10....
user2024080's user avatar
  • 5,171
7 votes
3 answers
14k views

Possible Duplicate: Generating random numbers in Javascript Hi.. I want to generate random numbers (integers) in javascript within a specified range. ie. 101-999. How can I do that. Does Math....
5 votes
3 answers
13k views

I am learning JavaScript and I want to make a simple rock paper scissors game. I want to make the computer choose the number 1, 2, or 3 at random and make the answer a variable called computerResponse....
3 votes
2 answers
27k views

Possible Duplicate: Generating random numbers in Javascript in a specific range? Say I wanted to generate a random number from 50 to 100. I know there's: Math.random() but I could only find ways ...
Alex's user avatar
  • 1,055
4 votes
4 answers
5k views

This maybe more mathematical question than programming. In JS I wanted to a function that returns a random integer number in an interval lets say 1-6 and this is what I found: // Returns a random ...
Adelin's user avatar
  • 19.2k
-5 votes
1 answer
12k views

i am confused about Math.Random() in javascript in know that this function will return a number between 0 and 1 i am trying to return a number between 400 and 500 and what i did is this : var y = ...
Sora's user avatar
  • 2,553
1 vote
3 answers
4k views

I wan't to generate a random number and use it as a class name for an element. Math.random(); This will generate a random number '0.7220265011042561' Since this will be used as a class within the ...
user avatar
0 votes
2 answers
3k views

I know about random that generates a random number between 0 and 1. Math.random(); But how can I generate a random number between 1 and 2,147,483,647 using Javascript?
Alan2's user avatar
  • 24.9k
-2 votes
1 answer
3k views

I'm following: window.onload = generateRandomNumber; function generateRandomNumber(){ var n = 25; var number = Math.floor(Math.random()*n)+1; document.getElementById("randomNumber").innerHTML = ...

15 30 50 per page
1
2 3 4 5
...
16