# 10 examples of 'javascript math floor math random' in JavaScript

Every line of 'javascript math floor math random' 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
``51function random(from, to) {52    return Math.floor(Math.random() * (to - from + 1) + from);53}``
``10function math_random_int(a, b) {11	if (a &gt; b) {12		// Swap a and b to ensure a is smaller.13		var c = a;14		a = b;15		b = c;16	}17	return Math.floor(Math.random() * (b - a + 1) + a);18}``
``13export function floor([number]) {14  return Math.floor(number);15}``
``73function floor(number) {74  return Math.floor(number * 10) / 10;75}``
``190function MathRand() {191    var myDate = new Date();192    var mytime = myDate.getTime();193    var Num = "";194    for (var i = 0; i &lt; 6; i++) {195        Num += Math.floor(Math.random() * 10);196    }197    Num = Num + "-" + mytime;198    return Num;199};``
``5static randomInt() {6    return Math.floor(Math.random() * Number.MAX_SAFE_INTEGER);7}``
``109function randomInt(a, b)110{111    assert (112        isInt(a) &amp;&amp; isInt(b) &amp;&amp; a &lt;= b,113        'invalid params to randomInt'114    );115116    var range = b - a;117118    var rnd = a + Math.floor(Math.random() * (range + 1));119120    return rnd;121}``
``78public static random(): number {79    return math.random();80}``
``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}``
``162function random999(){163  let a = Math.ceil(Math.random()*1000);164  if(a&gt;99){165    return a;166  }else{167    if(a&gt;9){168      return '0'+a;169    }else{170      return '00'+a;171    }172  }173}``