JSFiddle - React, Tailwind, and code Playground

by Cone

JavaScript

var sym = "1234567890=asdfghjklA*&?SDFGHJKLQWERTYUIOP!@#$%^()zxcvbnm,._-+";
var code = "";

function gencode(){
var rnum = Math.floor(Math.random() * sym.length);
code +=sym[rnum];         

    if(code.length < 9 || code[code.length-1] === rnum){
    gencode();
    }else {
    console.log(code);
        
    }
    
}

gencode();

/*
var ran;
var ds = 1;

function getran() {
    var ran = Math.floor(Math.random() * 200 + 1);

    if (ran < 200) {
        console.log(ran);
        ds++;
        getran();
    } else {
        console.log("ran is equal to " + ran + " after " + ds + " times");
    }
}

getran();

*/