This article describes the simple random number generation method of JS. Share it for your reference, as follows:
<!doctype html><html><head><meta charset="utf-8"><title>random number</title></head><body><script type="text/javascript">function Randnum(value){ var s=1000; var d=500; if(value=='b'){ document.write(s+parseInt(500*Math.random())); }else{ document.write(d+parseInt(500*Math.random())); }}</script><script>Randnum();</script></body></html>Reproduction image:
For more information about JavaScript algorithms, readers who are interested in this site can view the topics: "Summary of JavaScript Mathematical Operation Usage", "Summary of JavaScript Sorting Algorithm", "Summary of JavaScript Traversal Algorithm and Skills" and "Summary of JavaScript Data Structure and Algorithm Skills"
I hope this article will be helpful to everyone's JavaScript programming.