Code Monkey home page Code Monkey logo

tictactoe-react's Introduction

tictactoe-react

Create a game of tictactoe using react.

The starter code gives you a board component that outputs 3 rows and 9 spans.

Add the clickable elements to make the game playable.

http-server

You need to be able to serve the html file through your local network. Install http-server globally so that you can run the files: npm install -g http-server Run it in the directory: http-server

referencing elements

We need to capture data from the clicked element- we can use a traditional click event callback function:

At the component:

handleClick = (event, colIndex) => {
    // access to event.target here
    console.log(event);
}

In the JSX:

<button type="checkbox" onClick={((ev) => this.handleClick(ev, colIndex))}/>
    yay
</button>

Further

Nest your board component within a game component. Add other components as you see fit.

Further

Detect winning states. (hard-coded is ok)

Further

Add a score

Further

Make the columns and rows dynamic

Further

Make the winning state dynamic (3,4,5 in a row)

Further

Make a computer player

tictactoe-react's People

Contributors

awongh avatar sowyuen avatar

Watchers

 avatar

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.