What I intend to achieve is that by having a list of predefined words, I can make an undefined number of those words appear between 3 and 10 randomly. This is a script I managed to find:
var tad1 = new Array("#bre ","#bri ","#bri2 ","#brother ","#bro ","#bro2 ","#bru3 ","#bru4 ","#bru5 ","#bu ","#bu2 ","#bu3 ","#bu4 ","#bu5 ","#bu6 ","#bu7 ","#bu8 ","#bu9 ","#bu10 ","#bu11 ","#bu12 ","#bu13 ");
function tagAleatorio(){
aleat = Math.random() * tad1.length;
aleat = Math.floor(aleat);
return tad1[aleat];
};
document.write (tagAleatorio());
What I want is that more than one word from the list appears randomly in the document.
You can perform a function to get the number of elements in the array randomly.
To generate random letter we must first generate a number that is within the alphabet example from 0 to 25
Once we have the number we generate the letter by adding 97, understanding that ASCII numbering starts from 97
now we mix all this with a for to have a random word
Your code is fine to get a random word.
All that remains is to call that same code within a loop that concatenates words. Loop controlled by a random variable chosen between a minimum and a maximum.