Answer the question
In order to leave comments, you need to log in
How to assign random letters to a variable?
I want to make a command for discord so that it randomly displays a word from English letters. The number of letters is 18.
The problem is that I don't know how to do it. Here is Math.ceil(), but it is for numbers. And I wanted the same for letters.
If I do it through a function, then in response to the command I get function makeid ()
Here is the code:
var random = function makeid()
{
var text = "";
var possible = "abcdefghijklmnopqrstuvwxyz";
for( var i=0; i < 18; i++ )
text += possible.charAt(Math.floor(Math.random() * possible.length));
return text;
}
msg.channel.send(random)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question