Autify JavaScript Snippets
Toggle Dark/Light/Auto modeToggle Dark/Light/Auto modeToggle Dark/Light/Auto mode Back to homepage

Generate random integer

Use this snippet to create a random number.

Change the following values to fit your test case:

  • digit: Number of digits of random number
var digit = 10; /* TODO: REPLACE NUMBER */
return (
  Math.floor(Math.random() * (9 * Math.pow(10, digit - 1))) +
  Math.pow(10, digit - 1)
);