commit c64f2ce09ba329650ab51a7a2f66454b979d9a77 Author: Andrew Davidson Date: Mon Jan 29 05:46:03 2018 -0500 initial commit diff --git a/randomComment.js b/randomComment.js new file mode 100644 index 0000000..b84e8d0 --- /dev/null +++ b/randomComment.js @@ -0,0 +1,21 @@ +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);