import matchdone: matchdone + 1}); this.state.clicksperformed ++; }

import React from ‘react’;import ReactDOM from ‘react-dom’;import { Button } from ‘reactstrap’;import Card from ‘./Card’;function cardsInitialize(){  return { value: “A”, matched: false, flipped: false}, { value: “C”, matched: false, flipped: false}, { value: “B”, matched: false, flipped: false}, { value: “D”, matched: false, flipped: false}, { value: “A”, matched: false, flipped: false}, { value: “B”, matched: false, flipped: false}, { value: “C”, matched: false, flipped: false}, { value: “D”, matched: false, flipped: false}, { value: “E”, matched: false, flipped: false}, { value: “F”, matched: false, flipped: false}, { value: “H”, matched: false, flipped: false}, { value: “G”, matched: false, flipped: false}, { value: “F”, matched: false, flipped: false}, { value: “E”, matched: false, flipped: false}, { value: “G”, matched: false, flipped: false}, { value: “H”, matched: false, flipped: false},  ;}export default class Game extends React.Component{   constructor(props) {    super(props);    this.displayCards = this.displayCards.bind(this);    this.checkCardMatch = this.checkCardMatch.bind(this);    this.reset = this.reset.bind(this);    this.state = {      cards: cardsInitialize(),      locked: false,      finalcard: null,      matchdone: 0,      clicksperformed: 0    }; } checkCardMatch(value, id) {    if (this.state.locked) {      return;    }     var cards = this.state.cards;        cardsid.flipped = true;    this.setState({cards, locked: true});    if (this.state.finalcard) {      if (value === this.state.finalcard.value) {        var matchdone = this.state.matchdone;        cardsid.matched = true;        cardsthis.state.finalcard.id.matched = true;        this.setState({cards, finalcard: null, locked: false, matchdone: matchdone + 1}); this.state.clicksperformed ++;       } else {        setTimeout(() => {          cardsid.flipped = false;          cardsthis.state.finalcard.id.flipped = false;          this.setState({cards, finalcard: null, locked: false});        }, 2000); this.state.clicksperformed ++;       }    } else {      this.setState({        finalcard: {id, value},        locked: false      });    } }   displayCards(cards) {    return cards.map((card, index) => {      return (              );    });  }    reset() {    this.setState({      cards: cardsInitialize(),      finalcard: null,      locked: false,      matchdone: 0,      clicksperformed: 0    });  }    render() {    var btnText = ‘Restart Game’;    var scores;    if (this.state.matchdone === this.state.cards.length / 2) {      btnText = ‘Play Again?’;        if(this.state.clicksperformed === 8){      scores = 100;    }    if(this.state.clicksperformed > 8 && this.state.clicksperformed < 12){      scores = 80;    }    if(this.state.clicksperformed > 12){      scores = 60;    }    }        return (     

       

                    Scores Earned: {scores}       

        {this.displayCards(this.state.cards)}     

Best services for writing your paper according to Trustpilot

Premium Partner
From $18.00 per page
4,8 / 5
4,80
Writers Experience
4,80
Delivery
4,90
Support
4,70
Price
Recommended Service
From $13.90 per page
4,6 / 5
4,70
Writers Experience
4,70
Delivery
4,60
Support
4,60
Price
From $20.00 per page
4,5 / 5
4,80
Writers Experience
4,50
Delivery
4,40
Support
4,10
Price
* All Partners were chosen among 50+ writing services by our Customer Satisfaction Team

    );  }}