Homework 4 - Lots of Tic-Tac-Toe

  1. Here is an HTML file that has a tic tac toe board. Assume 2 people will take turns. Player 1 will type an X in an empty square and hit "Store Move". Then, player 2 will enter an O and hit "Store Move" and they will continue back and forth.

    Create a tic tac toe board that is stored in an array. Assume your array is all empty strings as play starts, e.g.

    var board = ["","","","","","","","",""];

    Every time someone hits "Store Move", you should put the values from the board into the array. For example, after a couple moves, the board values might be

    ["","O","","","X","","","",""]

    If someone hits "Reset", you should take the values in your array and put them into the board. Note: Do not call this function reset(). That is actually a reserved name that will reset your board to be empty. If you call your funtion reset(), it could simply not work. Pick any other name and you will be fine.

  2. Write a function that checks if there is a winner each time you store the move. If there is, show an alert declaring X or O the winner. Here’s a video to help.