Created
February 2, 2021 14:50
-
-
Save Shariar-Hasan/ffb7c7019610701326f886a30bb03a72 to your computer and use it in GitHub Desktop.
random number generator using function both string and number
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// genarate random number with specific digit using function | |
function randNumber(n){ | |
return Math.floor((Math.random()*10**n)); //if you want n digit random number as a number | |
} | |
function randNumString(n){ | |
return (Math.random()*10**n+" ").split('.')[0]; //if you want n digit random number as a string | |
} | |
randNumber(4); // calling the random number | |
randNumString(4); //calling the random nuber as a string |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment