JSFiddle - React, Tailwind, and code Playground

by frogggeee McFrogggeee

HTML

<!DOCTYPE html>
<html>
<head>
<body>
<h1>very strong password generator</h1>
<button type="button" onclick="generate()">generate password</button>
</body>
</head>
</html>

JavaScript

generate();
let password = "";
let which = 0;
let pl = Math.floor(Math.random() * 10) + 5;

let low = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"];
let caps = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"];
let num = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
let sym = ["!", "@", "#", "$", "%", "&", "*", ")", "(", "?", "/", ":"];
function generate() {

let i = 0;
pl = Math.floor(Math.random() * 10) + 5;
let sim = 0;
let thing = 0;
let l1 = Math.floor(Math.random() * 23);
let l2 = Math.floor(Math.random() * 23);
let l3 = Math.floor(Math.random() * 9);
let l4 = Math.floor(Math.random() * 11);
  for (i = 0;i < pl;i++) {
	  l1 = Math.floor(Math.random() * 23);
    l2 = Math.floor(Math.random() * 23);
    l3 = Math.floor(Math.random() * 9);
    l4 = Math.floor(Math.random() * 11);
    thing = Math.floor(Math.random() * 3);
    if (thing == 0) {
    	sim = low[l1];
    } else if (thing == 1) {
    	sim = caps[l2];
    } else if (thing == 2) {
    	sim = num[l3];
    } else if (thing == 3) {
    	sim = sym[l4];
    }
    password = password + sim;
  }
  alert (password);
}