- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to get a pseudo-random number between 0 and 1 in JavaScript?
To get a pseudo-random number between 0 and 1, use the Math.random() method in JavaScript.
Example
You can try to run the following code to get a pseudo-random number between 0 and 1 −
<html> <head> <title>JavaScript Math random() Method</title> </head> <body> <script> var value = Math.random( ); document.write("First Value : " + value ); value = Math.random( ); document.write("<br />Second Value : " + value ); </script> </body> </html>
Advertisements