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

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -