Script started on 2023-02-23 07:08:01+13:00 [COMMAND="vim -u '/home/void/personal/testie/testie2/vimkatrc' -R -c'set lines=91' +redraw +q '/home/void//personal/javascript-testie/DOM-interactions/game.js'" TERM="xterm-256color" TTY="/dev/pts/2" COLUMNS="-1" LINES="-1"] [?1049h[>4;2m[?1h=[?2004h[?12h[?12l[?25l"~//personal/javascript-testie/DOM-interactions/game.js" [readonly] 81 lines, 2647 bytes[?25h[?25l// Don't change or delete this line! It waits until the DOM has loaded, then calls // the start function. More info: // https://developer.mozilla.org/en-US/docs/Web/Events/DOMContentLoaded document.addEventListener('DOMContentLoaded', start) function start () { bindEventListeners(document.getElementsByClassName('board')[0].children); } function bindEventListeners (dots) { for (var i = 0 ; i < dots.length ; i++) { // BIND YOUR EVENT LISTENERS HERE // The first one is provided for you dots[i].addEventListener('contextmenu', makeGreen); dots[i].addEventListener('click', makeBlue); dots[i].addEventListener('dblclick', hide); } } // CREATE FUNCTION makeBlue HERE function makeBlue (evt) { if ( evt.target.className.includes('green') ) {evt.target.classList.toggle('green'); } evt.target.classList.toggle('blue'); updateCounts(); } function makeGreen (evt) { evt.preventDefault() if ( evt.target.className.includes('blue') ) {evt.target.classList.toggle('blue'); } evt.target.classList.toggle('green'); updateCounts(); } // CREATE FUNCTION hide HERE function hide (evt) { if ( evt.target.className.includes('blue') ) {evt.target.classList.toggle('blue'); } else if ( evt.target.className.includes('green') ) {evt.target.classList.toggle('green'); } evt.target.classList.toggle('invisible'); updateCounts(); } function updateCounts () { var totals = { blue: 0, green: 0, invisible: 0 } // WRITE CODE HERE TO COUNT BLUE, GREEN, AND INVISIBLE DOTS function countTotals (dot_array) {console.log('dot_array is:', dot_array);for (var n = 0 ; n < dot_array.length ; n++) {if ( dot_array[n].className.includes('invisible') ) {totals.invisible = totals.invisible + 1;console.log('Invisible changed to:', totals.invisible);} else if ( dot_array[n].className.endsWith('green') ) {totals.green = totals.green + 1;console.log('Green changed to:', totals.green);} else if ( dot_array[n].className.endsWith('blue') ) {totals.blue = totals.blue + 1;console.log('Blue changed to:', totals.blue);}}console.log('Totals are:', totals); } countTotals(document.getElementsByClassName('board')[0].children); // Once you've done the counting, this function will update the display displayTotals(totals); } function displayTotals (totals) { for (var key in totals) { document.getElementById(key + '-total').innerHTML = totals[key]; } } ~ ~ ~ ~ ~ ~ ~ ~ ~ [?2004l[>4;m[?2004l[?1l>[?1049l[?25h[>4;m Script done on 2023-02-23 07:08:01+13:00 [COMMAND_EXIT_CODE="0"]