I have the following code;
namedarray[\'India\']=\'New Delhi\';
namedarray[\'Australia\']=\'Canberra\';
namedarray[\'Indonasia\']=\'Jakarta\';
namedarray[\'I
I would just use two arrays for the data.
var countries = ['India', 'Australia', 'Indonasia', ... ];
var capitols = ['New Delhi', 'Canberra', 'Jakarta', ...];
Then insert into your text with:
var index = Math.floor(Math.random() * capitols.length);
document.getElementById('question').innerHTML="Q." +capitols[index]+" is capital for which country";
You can then use the index
variable to look up the answer later on as well.