lundi 15 janvier 2018

How do I get a random word of a certain length from an array?

I'd like to get a random string of a certain length (determined by an input field) from an array of strings. How can I do this?

I am currently able to get a random word from the array with this:

var word = arr[Math.floor(Math.random()*arr.length)];

How do I implement the word length specification?




Aucun commentaire:

Enregistrer un commentaire