Javascript random strings script, random number

Javascript random strings script, javascript random number script, random character

1

javascript random string and number

vc9uVH6qaSuLPBWJAUid
<input type="button" onclick="random_chars(10)" value="random text">
<div id="random-char-text"></div>

<script>
  function random_chars(length) {
    var result = "";
    var chars = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
    for (var i = 0; i < length; i++) {
      result +=  chars[Math.floor(Math.random() * chars.length)];
    }
    document.getElementById("random-char-text").innerText = result;
  }
</script>
2

javascript random number

06038139811258919436
<input type="button" onclick="random_number(10)" value="random number">
<div id="random-number-text"></div>

<script>
  function random_number(length) {
    var result = "";
    var chars = "1234567890";
    for (var i = 0; i < length; i++) {
      result +=  chars[Math.floor(Math.random() * chars.length)];
    }
    document.getElementById("random-number-text").innerText = result;
  }
</script>
3

random letters lowercase only

kwilwrugqxosyztnzawg
<input type="button" onclick="random_lower_case(10)" value="random text">
<div id="random-lower-text"></div>

<script>
  function random_lower_case(length) {
    var result = "";
    var chars = "abcdefghijklmnopqrstuvwxyz";
    for (var i = 0; i < length; i++) {
      result +=  chars[Math.floor(Math.random() * chars.length)];
    }
    document.getElementById("random-lower-text").innerText = result;
  }
</script>
4

random letter uppercase only

ZPZXMVZDJCBROJAYRIPN
<input type="button" onclick="random_upper_case(10)" value="random text">
<div id="random-upper-text"></div>

<script>
  function random_upper_case(length) {
    var result = "";
    var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    for (var i = 0; i < length; i++) {
      result +=  chars[Math.floor(Math.random() * chars.length)];
    }
    document.getElementById("random-upper-text").innerText = result;
  }

</script>
5

random number between (1000 2000)

1500
<input type="button" onclick="number_between(1000, 2000)" value="random number between">
<div id="number-btwn-text"></div>

<script>
  function number_between(min, max) {
    var min = Math.ceil(min);
    var max = Math.floor(max + 1);
    var result = Math.floor(Math.random() * (max - min)) + min;
    document.getElementById("number-btwn-text").innerText = result;
  }
</script>