gerd
6/9/2017 - 3:14 PM

Random number max and min inclusive

/*
Random number max and min inclusive
*/


var max = 10;
var min = 2
var number = Math.max(Math.floor(Math.random() * max) + 1, min);
console.log(number);
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>

<script id="jsbin-javascript">
/*
Random number max and min inclusive
*/


var max = 10;
var min = 2
var number = Math.max(Math.floor(Math.random() * max) + 1, min);
console.log(number);
</script>



<script id="jsbin-source-javascript" type="text/javascript">/*
Random number max and min inclusive
*/


var max = 10;
var min = 2
var number = Math.max(Math.floor(Math.random() * max) + 1, min);
console.log(number);</script></body>
</html>