best way to select random, corresponding data in javascript? -
i trying have like:
category = ("word1","word2","word3") ("definition1","definition2","definition3"); category1 = ("word1","word2","word3") ("definition1","definition2","definition3");
the basic goal select , output (lets 3) random words random category , able call on relevant data develop more (the category name , definition of word chosen randomly).
i don't want duplicates, , appreciate suggestions! :) lot!
you want structure array of objects:
category1 = [ { word: "word1", definition: "def1" }, { word: "word2", definition: "def2" }, { word: "word3", definition: "def3" } ];
then, select value category1
, pick category1[i]
@ random , use category1[i].word
, category1[i].definition
.
you can extend each object have additional properties later needed (numberofsylables
, gradelevel
, etc.)
Comments
Post a Comment