The getRandomInt() method is used to return a random number between two specified number.
Syntax:
getRandomInt(min, max)
Parameters: This method accepts two parameters as mentioned above and described below:
- min: This parameter holds the specified lower limit value.
- max: This parameter holds the specified upper limit value.
Return Value: This method returns the random number between min and max value (including). The output changes everytime you run the input file.
Example 1:
Javascript
<!DOCTYPE html> <html>     <head>      <!-- Adding the FabricJS library -->      <script src=      </script>   </head>     <body>     <script type="text/javascript">         // Calling getRandomInt() function over       // some specified min and max values       console.log(fabric.util.getRandomInt(1, 1));       console.log(fabric.util.getRandomInt(1, 2));       console.log(fabric.util.getRandomInt(1, 4));       console.log(fabric.util.getRandomInt(2, 10));     </script>   </body>   </html> |
Output:
1 2 2 8
Example 2:
Javascript
<!DOCTYPE html> <html>     <head>      <!-- Adding the FabricJS library -->      <script src=      </script>   </head>     <body>     <script type="text/javascript">         // Specifying some min and max values        var min1 = 1;        var max1 = 4;        var min2 = 12;        var max2 = 20;         // Calling getRandomInt() function over       // the above specified min and max values       console.log(fabric.util.getRandomInt(min1, max1));       console.log(fabric.util.getRandomInt(min2, max2));     </script>   </body>   </html> |
Output:
2 19

… [Trackback]
[…] Here you can find 41980 more Info to that Topic: geeksforgeeks.org/fabric-js-getrandomint-method-2/ […]
… [Trackback]
[…] Read More Info here to that Topic: geeksforgeeks.org/fabric-js-getrandomint-method-2/ […]
… [Trackback]
[…] Find More on to that Topic: geeksforgeeks.org/fabric-js-getrandomint-method-2/ […]
… [Trackback]
[…] There you will find 83200 more Info to that Topic: geeksforgeeks.org/fabric-js-getrandomint-method-2/ […]
… [Trackback]
[…] Information to that Topic: geeksforgeeks.org/fabric-js-getrandomint-method-2/ […]