Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
quote:
Originally posted by: JohnGree
hi Adam, that sound like what i had before, but what is the code to do this?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
You can make it super complicated:
number = Math.random()*35
if(number ==10){
number = a
} else if(number ==11){
number = b
} else if(number ==12){
number =c
} else if(number ==13){
number =d
} else if(number ==14){
number =e
} else if(number ==15){
number =f
}
etc.
It would be super long, but it works.( number is the name of a variable )
Copy link to clipboard
Copied
This code is also OK ( It seems that you just want a - u, change the code if you like)
list = new Array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, "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");
character = list[Math.round(Math.random()*35];
This code is a lot more simple!
Copy link to clipboard
Copied
If you have a list of letters to draw from, and don't mind if letters are repeated, then your algorithm (easily implemented in just a few lines of code) looks something like this: (don't ask me to write it...)