I want to make random words with letters provided via array with Javascript.
For example, I have a literal array that contains three letters:
var letters = ["a", "b", "c"];
I want to make random words by specifying "return 3 letters", for example:
abc
cba
bac
bba
ccb
I made a code that does something like this, but only returns 1 letter. I was wondering if there was a way to return a certain amount of letters?
Here is what I have (very simple):
var letters = ["a", "b", "c"];
var word = letters[Math.floor(Math.random() * letters.length)];
I know I can make an array, and fill it with "abc", "cba", etc. but I need it to make words with array values that are provided.