We have a form with two fields and a button. Do we want a random number int (for example, 3, 5 or 33) that would lie between int A and int B? (without using jQuery or anything like that)
You can use Javascript Math.random
function randomInRange(start,end){ return Math.floor(Math.random() * (end - start + 1) + start); }
Use something like Math.floor(Math.random()*(intB-intA +1)) + intA?
Math.floor(Math.random()*(intB-intA +1)) + intA
:
Math.floor(a + Math.random() * (b - a))
Math.random() [0,1) - 0 () ) 1 ().
Math.random()
Source: https://habr.com/ru/post/1782693/More articles:PHP: How to remove the last N bytes from a large file? - phpAdd .html when rewriting url in htaccess? - urlHow to use NGen.NET app correctly during installation - installerResolving name conflicts in C ++ - c ++Create a scaled circle of cards - mathMagento → I want the product grid in admin to be displayed in the interface - phpProblem with razor image and mvccontrib grid mesh - asp.net-mvcFailed to create useful yaml-cpp library (shared or static) with gcc 3.2.3 on Windows - yaml-cppCounting the number of objects matching certain criteria - javaQt: Как использовать Лептонику? - c++All Articles