Random number generator in JavaScript 🎲【4 minutes】

preview_player
Показать описание
#Javascript #random #number #generator

let x;
let y;
let z;

}
Рекомендации по теме
Комментарии
Автор

let x;
let y;
let z;

= function(){

x = Math.floor(Math.random() * 6) + 1;
y = Math.floor(Math.random() * 6) + 1;
z = Math.floor(Math.random() * 6) + 1;

= x;
= y;
= z;
}

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<label id="xlabel"></label><br>
<label id="ylabel"></label><br>
<label id="zlabel"></label><br>
<button type="button"
<script src="index.js"></script>
</body>
</html>

BroCodez
Автор

At 0:26 to be precise Math.random() will output a value of >= 0 and less than (not equal) to 1

buwithegoat
Автор

can you make a complete playlist like this on react js, please this is my first day on your channel and you are really life saver

alexdin
Автор

Ive learned more from you, than I ever did through my qualification courses.

Fadingsupernova
Автор

> discusses javascript
> elaborates
> doesn't leave you out

u r the best bro

jerogentil
Автор

great explanation of math.random()method

KhansaSaqib
Автор

I think math.ceil()is wanted to use there because then we don't want to add 1

SONICBOY_
Автор

"I like to play lot of D&D"... insta-subscribed 😅 Thanks so much for the JS tutorial!

AlessandroManente
Автор

This was a great video, as it helped correct me in doing a similar task. Thank you!

Dynamicsimpson
Автор

You can just use Math.ceil(Math.random() * 6) instead

francheeze
Автор

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🙂

galveraymundp.
Автор

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().

jaredkaye
Автор

instead of pressing roll 10 times, is there a way to print to the screen with the data 10 times?

ngocthangphan
Автор

thank you so much!! t's very helpful,

tommyho
Автор

when he rolled 5 5 times in a row its a 1 in 7776 chance (thanks calculator)

AexPays
Автор

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 to store them and add them

singh-vxhx
Автор

when you making plus 1 its random number between 1 and 7 and you didnt explain how to find numbers for example beteween 20 and 60

temotemo-lwdu
Автор

i copied the exact same codes but its not working for me

talstolo
Автор

Hi, i am looking for a code for generating unique username on registration form so pls advise.

amazingmoments