Skip to content

Instantly share code, notes, and snippets.

@premasagar
Created July 31, 2012 21:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save premasagar/3220886 to your computer and use it in GitHub Desktop.
Save premasagar/3220886 to your computer and use it in GitHub Desktop.
function round(num, decimalplaces){
return Number(num.toFixed(decimalplaces));
}
function randomInt(length){
return Math.ceil((length || 2) * Math.random()) - 1;
}
function randomRange(min, max){
return Math.random() * (max - min) + min;
}
function randomIntRange(min, max){
return randomInt(max + 1 - min) + min;
}
function now(){
return (new Date().getTime());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment