I have this function to randomly generate a country name for a quiz that I've been making, but I don't want the same name appearing more than once. How could I do that? Here is the code that I'm using.
<div style="float:left">
<h1> <span id="questionnum"></span>. Can you locate <span id="countryquestion"></span> on the map?</h1>
</div>
<script type="text/javascript">
generateCountry();
function generateCountry(){
filenames = [ "Albania", "Andorra", "Armenia", "Austria", "Azerbaijan", "Belarus", "Belgium", "Bosnia and Herzegovina", "Bulgaria", "Croatia", "Cyprus", "Czech Republic", "Denmark", "Estonia", "Finland", "France", "Georgia", "Germany", "Greece", "Hungary", "Iceland", "Ireland", "Italy", "Latvia", "Liechtenstein", "Lithuania", "Luxembourg", "Macedonia", "Malta", "Moldova", "Monaco", "Montenegro", "The Netherlands", "Norway", "Poland", "Portugal", "Romania", "Russia", "San Marino", "Serbia", "Slovakia", "Slovenia", "Spain", "Sweden", "Switzerland", "Ukraine", "United Kingdom" ];
filename = filenames[Math.floor(Math.random()*filenames.length)];
document.getElementById('countryquestion').textContent = filename;
}
</script>