10 examples of 'math.floor(math.random() * 2)' in JavaScript

Every line of 'math.floor(math.random() * 2)' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
46function randomInt(max) {
47 return Math.ceil(Math.random() * max)
48}
21export function randomInt(min, max){
22 return Math.ceil( min - 0.5 + (Math.random() * max));
23}
8function randomInt () {
9 return Math.round(Math.random() * 255)
10}
11randomInt(n) {
12 return Math.round(Math.random() * n);
13}
19function _random(max) {
20 return Math.round(Math.random() * 1000) % max;
21}
3function _random(max) {
4 return Math.round(Math.random()*1000)%max
5}
1function _random(max) {
2 return Math.round(Math.random()*1000)%max;
3}
5static randomInt() {
6 return Math.floor(Math.random() * Number.MAX_SAFE_INTEGER);
7}
112function randomInt(max: number): number {
113 return Math.floor(Math.random() * max);
114}
15export function getRandomInt(min = 0, max = 100) {
16 min = Math.ceil(min);
17 max = Math.floor(max);
18 return Math.floor(Math.random() * (max - min + 1)) + min;
19}

Related snippets