Math.random() JS

var rand = Math.random(1, 3);
alert(rand);

This code always gives out approximately the following numbers: 0.265656231225, it does not respond to the range at all. Always 0. What is the problem?

Author: Nick Volynkin, 2012-10-18

1 answers

function myrand(c_min,c_max){
  return Math.round(Math.random()*(c_max-c_min)+c_min);
}

Native random outputs a number in the range 0..1, so it is useless to beg, beg, and pass arguments

 7
Author: knes, 2012-10-18 10:04:40