Friday, January 22, 2021

Generate random number in javascript

The following code generate the random number between 1 to 900
<html>
<head>
<title>Random number in javascript</title>

<script>
getRandom();
function getRandom() {
var random_no = Math.floor(Math.random() * 900) + 1;
alert(random_no);
}

</script>
</head>
<body>
<h1>Random number in Javascript!</h1>
</body>
</html>

No comments:

Post a Comment

Featured Post

What is JavaScript? What is the role of JavaScript engine?

  The JavaScript is a Programming language that is used for converting static web pages to interactive and dynamic web pages. A JavaScript e...