var li = document.getElementsByTagName("li"); console.log("Found ", li.length, " li tags"); var comments = []; for (var l = 0; l < li.length - 1; l++) { if (li[l].classList.contains("comment")) { if (li[l].classList.contains("comment-author-bernie") == false) { comments.push(li[l]); } } } console.log("Found ", comments.length, " comments not by Bernie"); console.log("Choosing winner..."); var winner = comments[Math.floor(Math.random() * comments.length)]; winner.querySelector("article").style.background = "gray"; winner.scrollIntoViewIfNeeded(); // alert("The winner is: ", winnerName);