GithubHelp home page GithubHelp logo

w1_tic_tac_toe's Introduction

Tic Tac Toe - Weekend Lab

Objective: Build a tic-tac-toe game in HTML and pure JavaScript.

This week, we've been learning about working with conditionals and loops, as well as writing functions. We've also learned about the structure of the DOM and how we can interact with it using CSS and JavaScript.

For your first weekend lab, we'll be making a tic-tac-toe game using your knowledge and skills from this week.

Minimum Requirements

  • A user should be able to click on different squares to make a move.
  • Every click should alternate between marking an X and O.
  • When marking an individual cell, use JavaScript to add a class to the cell to display separate colors for X's and O's.
  • A cell should not be able to replayed once marked.
  • Add a reset button that clears the contents of the board.

How to Get Started

  1. Fork this repository, and clone it onto your local computer.

  2. Use index.html as your starting point on this project. There is already some starter code in index.html, style.css, and ticTacToe.js. Make sure you link your CSS and JavaScript files to your index.html.

  3. Test that your CSS and JavaScript files are linked to your index.html by adding an alert to ticTacToe.js and opening index.html in the browser. You should see an empty tic-tac-toe game board, and you should also see your alert message pop up.

  4. The next step is to create the tic-tac-toe game-play with JavaScript:

    • First locate DOM elements before trying to use them in your app. Think about using querySelector or querySelectorAll to locate your target elements. Try this in your console to make sure your selection works.
    • After finding the elements, start writing logic using addEventListener to set up click events for those elements.
    • You will also need a variable to keep track of moves. This will be used to indicate whether or not to draw an X or an O.
  5. Submit the link to your GitHub repo in the homework submission form.

Bonus

  • Display a message to indicate which turn is about to be played.
  • If a player wins with three in a row, stop the game and alert the winner.
    • Hint: Determine a set of winning combinations. Check those combinations against the board contents after every move.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.