Hello Friends, In this post, you will undergo a javascript code example that helps you to generate random number using the crypto class.

Generate a random number using the crypto class in javascript 

Previously, we used the Math class of javascript to generate a random number, but in the modern way we can used the Crypto class to generate a random number, that let us allow to write less amount of code that easy to understand. So let's see an example that will give us clear picture of this concept,

Example:

 const myArray = new Uint32Array(1);
 let text = crypto.getRandomValues(myArray)[0];
 console.log('RandomNumber>>>>'+text);
Output:

Hope you like this post. For any feedback or suggestions, please feel free to comment. I would appreciate your feedback and suggestions.
Thank you.