Last active
July 14, 2019 00:20
-
-
Save g-rohit/f6760d98ff0d26d6454c6f84391042c1 to your computer and use it in GitHub Desktop.
Print random alphabet letters / words
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var alphabet = "abcdefghijklmnopqrstuvwxyz"; | |
console.log(alphabet[Math.floor(Math.random() * alphabet.length)]); | |
// Priting random 6 letters word | |
var alphabet = "abcdefghijklmnopqrstuvwxyz"; | |
var random = ""; | |
for (i = 0;i < 6 ; i ++) { | |
random = random + alphabet[Math.floor(Math.random() * alphabet.length)]; | |
} | |
//print random password containing atleast 1 uppercase, 1 lowercase, 1 number and 1 special character | |
var lowerAlphabet = "abcdefghijklmnopqrstuvwxyz"; | |
var upperAlphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; | |
var number = "0123456789"; | |
var specialChar = "!@#$%&*"; | |
var random = ""; | |
for (i = 0;i < 4 ; i ++) { | |
random = random + lowerAlphabet[Math.floor(Math.random() * lowerAlphabet.length)] + number[Math.floor(Math.random() * number.length)] + upperAlphabet[Math.floor(Math.random() * upperAlphabet.length)]+ specialChar[Math.floor(Math.random() * specialChar.length)] ; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment