Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,895 questions

51,826 answers

573 users

How to generate random number between range in Node.js

2 Answers

0 votes
function random_between_rang(min, max) {  
    return Math.floor(Math.random() * (max - min + 1) + min);
}

var i = 0;
while (i < 20) {
	console.log(random_between_rang(3, 9)); // 3 - 9
	i++;
}




/*
run:

1
7
6
7
7
1
4
5
1
0
4
7
1
1
0
7
6
1
6
2

*/

 



answered Oct 14, 2021 by avibootz
0 votes
function random_between_rang(min, max) {  
    return Math.floor(Math.random() * (max - min) + min);
}

var i = 0;
while (i < 20) {
	console.log(random_between_rang(3, 9)); // 3 - 8
	i++;
}




/*
run:

7
5
6
8
6
4
7
6
5
4
3
6
4
4
3
3
7
3
5
7

*/

 



answered Oct 14, 2021 by avibootz

Related questions

...