lundi 29 mai 2017

How do I create a random property inside a randomly selected object?

For example, if I have:

var weapon = [
"sword",
"mace",
"staff"];

var swordtype = [
"long",
"short"];

var stafftype = [
"quarter",
"magic"];

and my script randomly selects 'Sword' to display in my html p tag from the weapon variable.

How can I say that if my code randomly selects "Sword" from the weapon variable, it will also randomly select a "swordtype" to go with it? Making the output either "long sword" or "short sword"?




Aucun commentaire:

Enregistrer un commentaire