Skip to content

Instantly share code, notes, and snippets.

@dhirajforyou
Created March 13, 2015 11:04
Show Gist options
  • Save dhirajforyou/1ade3b045ec566e50c03 to your computer and use it in GitHub Desktop.
Save dhirajforyou/1ade3b045ec566e50c03 to your computer and use it in GitHub Desktop.
Javascript Random Number Generator Function
/*
Attaching the time stamp so that based on the returned value , we can find out when it is generated
*/
function _Random(){
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx-te'.replace(/[xye]/g, function (c) {
var r = Math.random() * 16 | 0;
if(c == 'e'){ var t = (new Date).getTime(); v = t}
else{var v = c == 'x' ? r : (r & 3 | 8);}
return v.toString(16);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment