JSFiddle - React, Tailwind, and code Playground

JavaScript

var N = 500, html = '<style>div {height: 1px; background-color: red;}</style>', wrong = true;
for (var i = 0; i < N; i++) {
    html += '<div></div>';
}
$('body').html(html);
var items = $('div');
function removeElement() {
    var i = Math.floor(Math.random()*N), counter = 10000;
    if (wrong) {
        while ($(items[i]).data('checked') && i<N) i++;
    } else {
        while ($(items[i]).data('checked') && counter-->0) i = Math.floor(Math.random()*N);
    }
    $(items[i]).data('checked', true);
    $(items[i]).css('background-color', 'green');
    setTimeout(removeElement, 10)               
}
removeElement();