document.querySelectorAll('input[type="checkbox"]').forEach(function(checkbox) { checkbox.checked = Math.random() >= 0.5; });