Lesson 5 Tinker task
by nathanesa
JavaScript
//arrays
var adjectives = ['happy', 'dark', 'dizzy', 'ghastly', 'crazy', 'blue', 'shiny', 'tremendous', 'silly', 'extreme'];
var nouns = ['camel', 'apricot', 'light', 'bones', 'monkey', 'piano', 'star', 'elephant'];
var numbers = ['79', '13', '46', '62', '82', '26', '97', '85', '32', '66', '21', '98'];
var specialCharacters = ['$', '!', '#', '%', '*'];
//random number
var adjRand = Math.floor(Math.random()*10);
var nounsRand = Math.floor(Math.random()*8);
var numbersRand = Math.floor(Math.random()*12);
var specialRand = Math.floor(Math.random()*5);
//output password
document.write('PASSWORD GENERATOR:' + '<br>');
var answer = prompt('Do you want a special character? y / n');
if (answer == 'y') {
document.write(adjectives[adjRand] + nouns[nounsRand] + numbers[numbersRand] + specialCharacters[specialRand]);
} else {
document.write(adjectives[adjRand] + nouns[nounsRand] + numbers[numbersRand]);
}