Giter Site home page Giter Site logo

memory-card's Introduction

Continuing journey with React. Last project was all about basic stuff, and later using Hooks to replace simple Classes with functions. This time I'm going to use Effects, maybe lifecycle methods. but hopefully Hooks will be enough.


This project was fast and easy. I did have little trouble getting started but after I sat down, thought how I'm gonna implement everything, and then made notes and drafts on paper, rest was a breeze. So not much to say about this project. I like using Hooks and Effects etc. It makes writing React so much smoother experience. Especially after first learning to do everything with Classes.

Basically I just made a array of pictures. And used Math.random to make always an array with randomized numbers from 1 to 12. Then I assigned every rendered card with a certain index from the number array and used it's value to pick the picture for the card.

All I had to do then was to use useEffect to randomize cards everytime score was changing. When card was clicked I concated it to a separate array. Every turn the game checks if the next card is in that array, and based on that it either raises player's score, or restarts the game (and sets the hiScore to match the highest score.)

memory-card's People

Contributors

pettle avatar

Stargazers

Gustavo Souza 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.