$(function() {
max = 25;
min = 1;
var i = 0;
do {
var match = Math.ceil(Math.random() * (max - min )- min);
$('td').each(function() {
i++;
console.log( match );
if (i == match) {
$(this).addClass('active');
}
})
} while ($('td.active').length == 10);
})
My problem is that I do not return 10 random boxes but only one.
Change
to
while!=untilBut if you have less than 10
td, you’ll loop indefinitely. And it will very often break asialways grows bigger.I think you want this :