Game-3in-a-row/PROG2700-Assignment4B-3inarow_StarterFiles/game.js
// FUNCTION: This function makes a fetch call using the url variable to attain the json data needed to run the game. If passes the returned data to the setGameGrid function. 
This function makes a fetch call using the url variable to attain the json data needed to run the game. If passes the returned data to the setGameGrid function.
This function makes a fetch call using the url variable to attain the json data needed to run the game . If passes the returned data to the setGameGrid function .
function startGame() {
      if (localStorage.getItem('3-in-A-Row-Game-Data') === null) {
        fetch(url)
          .then(res => res.status === 200 ? res.json() : null)
          .then(data => {
            gameJsonData = data;
            createGameElements(gameJsonData);
          })
          .catch(err => console.log(err + ": Error Encountered while loading data."));
      }
      else {
        setTimeout(() => {
          gameJsonData = loadGameSave(); 
          createGameElements(gameJsonData);
        }, 100);
      }
    }
function startGame ( ) { if ( localStorage . getItem ( '3-in-A-Row-Game-Data' ) === null ) { fetch ( url ) . then ( res => res . status === 200 ? res . json ( ) : null ) . then ( data => { gameJsonData = data ; createGameElements ( gameJsonData ) ; } ) . catch ( err => console . log ( err + ": Error Encountered while loading data." ) ) ; } else { setTimeout ( ( ) => { gameJsonData = loadGameSave ( ) ; createGameElements ( gameJsonData ) ; } , 100 ) ; } }
FUNCTION: This function makes a fetch call using the url variable to attain the json data needed to run the game.
FUNCTION : This function makes a fetch call using the url variable to attain the json data needed to run the game .
// fetch call to get new game data // used to delay game load until HTML is loaded in browser. // function returns json from local storage