xxxxxxxxxx
40
// create a program that gives us a password of a
// desired lenght. Just letters
// Shopping List
// We need to get the desired length
// We need to have all the letters of the alphabet
// Find a function to get a random letter
// run the random function the desired number of times
// Each time add a new letter to the password
let lengthOfPassword = 56;
let lettersOfAlphabet = "abcdefghijklmnopqrstuvwxyz";
let numbersToAdd = '0123456789';
let symbolsToAdd = '!@#$%^&*';
let myPassword = '';
function setup() {
createCanvas(400, 300);
}
function getRandomLetter() {
let allSymbols = lettersOfAlphabet + lettersOfAlphabet.toUpperCase() + numbersToAdd + symbolsToAdd;
let randomIndexOfAlphabet = Math.floor(random(allSymbols.length));
let chosenLetter = allSymbols[randomIndexOfAlphabet];
return chosenLetter;
}
function createPassword(){
for(let i = 0; i < lengthOfPassword; i++){
myPassword += getRandomLetter();
}
return myPassword;
}
function draw() {
background(48, 84, 122);
console.log(createPassword());
noLoop();
}