Game-3in-a-row/PROG2700-Assignment4B-3inarow_StarterFiles/game.js
// FUNCTION: This function loops through all of the tiles on the page and uses the current tiles dataset values to find its corresponsing object in the rows array. It then uses that object to see if the current tile is correct. If it is not correct an error indicator is inserted into the tile. Once the checkbox has been turned off the loop removes error indicators. 
This function loops through all of the tiles on the page and uses the current tiles dataset values to find its corresponsing object in the rows array. It then uses that object to see if the current tile is correct. If it is not correct an error indicator is inserted into the tile. Once the checkbox has been turned off the loop removes error indicators.
This function loops through all of the tiles on the page and uses the current tiles dataset values to find its corresponsing object in the rows array . It then uses that object to see if the current tile is correct . If it is not correct an error indicator is inserted into the tile . Once the checkbox has been turned off the loop removes error indicators .
function displayIncorrectSquares() {
      document.querySelectorAll('td').forEach(tile => {
        let tileObject = gameJsonData.rows[tile.attributes[0].value][tile.attributes[1].value];
        if (document.querySelector('input[type="checkbox"]').checked) {
          if (tile.childNodes.length > 0) {
            tile.removeChild(tile.lastChild);
          }
          if (tileObject.currentState !== tileObject.correctState) {
            let errorTextElement = document.createElement('p');
            errorTextElement.appendChild(document.createTextNode("X"));
            tile.appendChild(errorTextElement);
          }
        }
        else {
          if (tile.childNodes.length > 0) {
            tile.removeChild(tile.lastChild);
          }
        }
      });
    }
function displayIncorrectSquares ( ) { document . querySelectorAll ( 'td' ) . forEach ( tile => { let tileObject = gameJsonData . rows [ tile . attributes [ 0 ] . value ] [ tile . attributes [ 1 ] . value ] ; if ( document . querySelector ( 'input[type="checkbox"]' ) . checked ) { if ( tile . childNodes . length > 0 ) { tile . removeChild ( tile . lastChild ) ; } if ( tileObject . currentState !== tileObject . correctState ) { let errorTextElement = document . createElement ( 'p' ) ; errorTextElement . appendChild ( document . createTextNode ( "X" ) ) ; tile . appendChild ( errorTextElement ) ; } } else { if ( tile . childNodes . length > 0 ) { tile . removeChild ( tile . lastChild ) ; } } } ) ; }
FUNCTION: This function loops through all of the tiles on the page and uses the current tiles dataset values to find its corresponsing object in the rows array.
FUNCTION : This function loops through all of the tiles on the page and uses the current tiles dataset values to find its corresponsing object in the rows array .
// checks to see if the show errors checkbox is checked // removes current nodes from all tiles // Adds indicator that tile is incorrect // if checkbox is not checked it removes error indicators