I'm fairly new to programming and I've been working on a project that finds four random divs and adds a class to them -- my only problem is that because my random generator has been generating the same number frequently, the program usually does not append the class to FOUR random divs but most likely three or even two. So my question is, how, if possible would I set my program to only generate four DIFFERENT numbers. I've heard of the Fisher Yates attempt, but I did not get it fully. Here is my JS:
for(var i = 4; i>0; i--){
var rand = Math.floor((Math.random()*16)+1);
var array=new Array();
array[1] = "one";
array[2] = "two";
array[3] = "three";
array[4] = "four";
array[5] = "five";
array[6] = "six";
array[7] = "seven";
array[8] = "eight";
array[9] = "nine";
array[10] = "ten";
array[11] = "eleven";
array[12] = "twelve";
array[13] = "thirteen";
array[14] = "fourteen";
array[15] = "fifteen";
array[16] = "sixteen";
$('#'+array[rand]).addClass('bomb');
}
Thanks a lot to any help!