5. Write a JavaScript to generate two random numbers and find out maximum and minimum out of it.
<html>
<head>
<title>EX-5: WTAD : www.bipinrupadiya.com</title>
<script type="text/javascript">
function bsr()
{
var rnd1=Math.floor(Math.random()*100);
var rnd2=Math.floor(Math.random()*100);
document.write('<br>Random No.1 : ' + rnd1);
document.write('<br>Random No.2 : ' + rnd2);
if (rnd1 < rnd2)
{
document.write('<br><br>Minimum No.:' + rnd1);
document.write('<br>Maximum No.:' + rnd2);
}
else
{
document.write('<br><br>Minimum No.:' + rnd2);
document.write('<br>Maximum No.:' + rnd1);
}
}
</script>
</head>
<body onLoad='bsr();'>
</body>
</html>
Subscribe to:
Post Comments (Atom)
Subjects
- WordPress
- Mobile Computing-4649303 Practical Solution
- Android Programming New Syllabus Theory
- PHP LAMP Question Bank
- PHP LAMP Theory
- Step by Step Android Example
- Android Practical
- Android Theory
- Android Question Bank
- Networking FON Practical
- Networking FON Theory
- OS Practical
- OS Theory
- HTML
- JavaScript
- J2EE WTAD Theory
- J2EE WTAD Question Bank
- J2EE WTAD Quick Guide
- J2EE WTAD GTU Papers
- J2EE WTAD Practical
- Python
- JAVA Theory
- JAVA Practical
- MIS
Categories
- Android (55)
- CSS (3)
- Configure Tomcat7 (2)
- Decryption (16)
- Difference (1)
- Encryption (16)
- Error Detection and Correction Techniques (3)
- FON (27)
- Framing Technic (2)
- J2EE (29)
- JAVA (13)
- JavaScript (19)
- OS (17)
- PHP (11)
- Protocol (3)
- SERVER SOCKET PROGRAMING (7)
- Servlet (13)
- WTAD (34)
- c (11)
- install Tomcat (2)
- linux (8)
- shell script (33)
- unix (22)
Blog Archive
-
▼
2012
(79)
-
▼
January
(16)
- 15. Assume that we have got three pdf files for th...
- 14. Write a Servlet which displays a message and a...
- 13. Write a Servlet to display all the attributes ...
- 12. Write a Servlet to display parameters availabl...
- 11. Write a Servlet to display all the headers ava...
- create GenericServlet
- 9. Write a JavaScript to show a pop up window with...
- 8. Write a JavaScript to find a string from the gi...
- 7. Write a JavaScript to convert Celsius to Fahren...
- 6. Write a JavaScript to remove the highest elemen...
- 5. Write a JavaScript to generate two random numbe...
- 4. Write a JavaScript that finds out multiples of ...
- 3. Create a Form in HTML with two fields, minimum ...
- 2. Write a JavaScript that demonstrates the use of...
- 1. Write a JavaScript that shows how a variable’s ...
- getting "android write to sdcard permission denied...
-
▼
January
(16)
Total Pageviews
© BipinRupadiya.com. Powered by Blogger.

2 comments:
This is a simple and clear example of using JavaScript’s Math.random() and Math.floor() to generate two values and then compare them to determine the minimum and maximum. The conditional logic is easy to follow, making the example useful for beginners who are learning variables, random number generation, comparison operators, and if-else statements. A Javascript Online Course can provide a broader foundation for these JavaScript programming concepts.
I also like that the example keeps the logic compact: two random numbers are generated, displayed, compared, and then the appropriate minimum and maximum values are printed. These basic programming exercises are useful for building the reasoning skills needed before moving into more structured TypeScript development, making a TypeScript Online Course a natural next step for learners progressing from JavaScript fundamentals.
Post a Comment