Practicing... Document roll *********************************** //Generating a random decimal number between 0 and 1 /* let x = Math.random(); console.log(x); */ //Generating a random number between 1 and 6(with a dice) but 0 and 5 technically /* let x = Math.random() * 6; console.log(x); */ //Generating a random number between 0 an 5 /* let x = Math.floor(Math.random() * 6); console.log(x); */ //Generating a random number between 1 and 6 /* let x = Math.floor(Math.random() * 6) + 1; console.log(x); */
Hmm I wanted to know how math.random() selects the number. In WoW /roll would give the dice roll for loot and casinos. I thought it was derived from the time frequency. CLA3 AI is describing itself with javaScript and math.random().
what if I want it to have two input box where you can put the maximum and minimum that will generate 6 random numbers (EXAMPLE : Min: 1 Min:2 *press generate button Output: 2,1,3,5,7,6) please help🙂
how to add the number just using one time math.floor. Suppose first time it gives 5 and next time it five 6 ...I want to add them by only using one time math.floor........how to store them and add them
depends on the browser and the architecture, in most cases, you can't really tell... digging through the v8 engine source code i found a lot of different ways they create random numbers, so as far as i can see, you'll have to create your own seeded random function, a good starting point would be something called a "linear feedback shift register" and maybe some of your own implementations (just from the top of my head you could hash the seed you got, and interpret that as a value from 0 to 1)
As someone who currently follows the guide, most classes in the course work on the latest version. Currently at a 2 hour point of the whole thing but i couldn't do only one lesson, that being dictionaries.
@Dude, I am not an alien... If you're talking about javascript, try this out: function random() { let variable = Math.floor(Math.random() * 9) + 1; alert("Your random number is " + variable); } You can repeat this as much as you want to.